Compare commits

..

182 Commits

Author SHA1 Message Date
Alix JEUDI--LEMOINE 64c5df029d Ajout d'1 DELETE pour exemple
1 year ago
Victor SOULIER 3fef170148 [test] fix str
1 year ago
Victor SOULIER f5d8fd7877 [test] exclusion
1 year ago
Victor SOULIER c648b97211 [test]
1 year ago
Victor SOULIER c74fdd5d05 [test] fix str
1 year ago
Victor SOULIER 80a1e6578f [Test] inclusion target
1 year ago
Victor SOULIER abe3a9bdfa ajout sonar
1 year ago
Victor SOULIER f739ac77d9 Merge branch 'master' into Springboot
1 year ago
Victor SOULIER 333fc8785c fix calcul score
1 year ago
Victor SOULIER fd6674205f ajout get + patch pour invite
1 year ago
Victor SOULIER 9705bd358f fix affichage de temps d'affichage du socre manquant sur le dto de partiekahoot status
1 year ago
Victor SOULIER fd688a10f7 fix contains
1 year ago
Victor SOULIER 85d737845f fix pb cors
1 year ago
Victor SOULIER 78b0991962 ajout temporisation pour score avec etat
1 year ago
Alix JEUDI--LEMOINE 2e523e7161 Mise à jour connexion (erreur non souhaitée)
1 year ago
Alix JEUDI--LEMOINE d58b2da32b Modification trompé emplacement + test
1 year ago
Alix JEUDI--LEMOINE 7eeca2f899 Modification application.properties pour prendre en compte la var env + le local
1 year ago
Alix JEUDI--LEMOINE 8d63bc0bd3 Ajout variables ENV pour identification DB (celles présentes dans le code étant pour le dev local)
1 year ago
Alix JEUDI--LEMOINE df22457e89 Désactivation adminer
1 year ago
Alix JEUDI--LEMOINE 05b9801d1b Remove code analysis
1 year ago
Alix JEUDI--LEMOINE 266b31fbc7 Changement commande
1 year ago
Alix JEUDI--LEMOINE 50052df70d Test ajout code-analysis
1 year ago
Alix JEUDI--LEMOINE 48ca6b6b05 Ajout gwen admin
1 year ago
Alix JEUDI--LEMOINE bebf6f9c72 Correction environnement
1 year ago
Alix JEUDI--LEMOINE 8eae4a5145 Test modif headers
1 year ago
Alix JEUDI--LEMOINE 73872188e5 Remove context path
1 year ago
Alix JEUDI--LEMOINE a8fd1efa0a Test modif private
1 year ago
Alix JEUDI--LEMOINE eb2a643d49 Test change port
1 year ago
Alix JEUDI--LEMOINE e6ee9c3cf3 Change expose
1 year ago
Alix JEUDI--LEMOINE 4ea32c20b6 Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE a17a0322c0 Ajout Dockerfile
1 year ago
Alix JEUDI--LEMOINE 5108b61647 Modification pipeline
1 year ago
Alix JEUDI--LEMOINE c622fb308d Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE 98622dfad2 Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE 1f20957239 Test modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE 078bf2b51a Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE 4c08ea4932 Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE 067fc64bd8 Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE c6bc3460b9 Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE 69a73de3d6 Test modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE 4a76d4b7fa Test modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE f17815eda1 Modification .drone.yml
1 year ago
Alix JEUDI--LEMOINE fc4e653bb8 Ajout .drone.yml
1 year ago
Victor SOULIER 8a85187eac fix error msg
1 year ago
Victor SOULIER 23dabb0350 suppression attribut à ne pas afficher sur le dto
1 year ago
Victor SOULIER 5604d9843c suppression attribut jeu inutilisé
1 year ago
Victor SOULIER 567be9b94f ajout route status
1 year ago
Victor SOULIER 30647d93e3 ajout calcul score
1 year ago
Victor SOULIER 70ff5a6fa2 ajout transition entre question
1 year ago
Victor SOULIER 2a2b84c55b ajout méthode question suivente
1 year ago
Victor SOULIER 28d4ac77b6 fix sauvegarde réponse
1 year ago
Victor SOULIER 3f61e5252e ajout système de réponse
1 year ago
Victor SOULIER 1a0382e9d0 ajout getQuestion pour PartieKahoot
1 year ago
Victor SOULIER 0391f7c75f ajout temps limite
1 year ago
Victor SOULIER 5cb6e5c108 correction many2many en vu de l'utilisation du stockage des réponses des joueurs par questoins
1 year ago
Victor SOULIER c646d15a25 fix dto
1 year ago
Victor SOULIER 8c1a4681b1 setup question actuel au lancement de la partie
1 year ago
Victor SOULIER b6e4a995d3 utilisation constante pour le nombre de question
1 year ago
Victor SOULIER 1ddd0e1e5c fix initiation score à l'ajout d'un joueur
1 year ago
Victor SOULIER 161ae36542 ajout gestion initiation score
1 year ago
Victor SOULIER 504204e892 fix package name
1 year ago
Victor SOULIER b58c6beab0 ajout route pour démarrer une partie kahoot
1 year ago
Victor SOULIER ec83e38920 fix erreur de syntaxe
1 year ago
Victor SOULIER c40b54eef7 fix default value of partie
1 year ago
Victor SOULIER 3a3f7f4107 suppression import inutilisés
1 year ago
Victor SOULIER e31ae6744d ajout status
1 year ago
Victor SOULIER faf5014cfe ajout requête récupération questions random selon difficulte et thematique
1 year ago
Victor SOULIER 649f9431c6 ajout service, controller, entity pour partiekahoot
1 year ago
Victor SOULIER 68e6228e4e Merge remote-tracking branch 'origin/Springboot' into Springboot
1 year ago
Victor SOULIER fa3ec7692e fix get id pour partie
1 year ago
Victor SOULIER 1f1143236e fix condition Pending
1 year ago
Victor SOULIER eb43a0f8f2 ajout partie kahoot et many2many pour questions de la partie (Entity pas implémenté)
1 year ago
Victor SOULIER 30e9e33814 ajout attribut estvalid sur reponse
1 year ago
Victor SOULIER e031a2f4d8 ajout status dans dto + correction nom enum
1 year ago
Victor SOULIER 9c8d400a00 valeur par défaut pour status de partie + utilisation ENUM
1 year ago
Victor SOULIER 7a878f9fb4 ajout difficulte selectionnée dans partie
1 year ago
Victor SOULIER c5ca57d521 ajout thematique selectionnées dans partie
1 year ago
Victor SOULIER fd052fe673 suppression import inutilisé
1 year ago
Victor SOULIER da14da0115 ajout route creation d'un invité
1 year ago
Victor SOULIER b8982b3e8e fix champs obligatoires
1 year ago
Victor SOULIER c5009c3d35 ajout route pour ajouter des joueurs à une partie
1 year ago
Victor SOULIER 0d6c771c26 get by codeInvitation or ID
1 year ago
Victor SOULIER cbebbe2cf2 correction creation partie, ajout dto correspondant
1 year ago
Alix JEUDI--LEMOINE d519ef3554 Ajout inutile
1 year ago
Alix JEUDI--LEMOINE 3d3ffe86f0 Ajout model Request pour pseudo dans RequestBody - mauvaise chose je pense -
1 year ago
Alix JEUDI--LEMOINE 4bf5e2276f Ajout controller Invite
1 year ago
Alix JEUDI--LEMOINE ca14536968 Revert modif inutile
1 year ago
Alix JEUDI--LEMOINE ef35f0911c Test modif
1 year ago
Alix JEUDI--LEMOINE c419ab47b2 Ajout service Invite (pas parfait encore, Utilisateurs pas pris en compte seulement Joueur)
1 year ago
Alix JEUDI--LEMOINE 06b493b561 Ajout controller Jeu (routes GET /api/v1/jeux & /api/v1/jeux/{id})
1 year ago
Alix JEUDI--LEMOINE d459563cce Ajout getPartieByCodeInvitation pour rejoindre par invite
1 year ago
Alix JEUDI--LEMOINE 3750490f07 Ajout exception partie déjà démarrée
1 year ago
Alix JEUDI--LEMOINE 43b077c6f5 Ajout constructeur par défaut à MalformedPartyException
1 year ago
Alix JEUDI--LEMOINE 1ae0bc940f Modification controller Partie pour createPartie fonctionnel
1 year ago
Alix JEUDI--LEMOINE 10965995e0 Création model pour Request create party
1 year ago
Alix JEUDI--LEMOINE db1bd37c04 Fichier inutile
1 year ago
Alix JEUDI--LEMOINE be2570813f Ajout status + dateCreation dans l'entité Partie
1 year ago
Alix JEUDI--LEMOINE f655f37284 Ajout exceptions notFound Jeu/Invite
1 year ago
Alix JEUDI--LEMOINE fa5883ceb2 Ajout JsonIgnore pour éviter l'apparition de la partie sur un Joueur dans le JSON de la partie (boucle infinie sinon)
1 year ago
Alix JEUDI--LEMOINE 491b9c740e Ajout création de partie (belle galère ça)
1 year ago
Alix JEUDI--LEMOINE e0ca2c700c Modification schema base pour ajouter un status et une date de création sur les parties + ajout fonction création uid pour codeInvitation + création controller Invite + Jeu + création nouveau DTO + 3 exceptions + InviteService
1 year ago
Alix JEUDI--LEMOINE aa61035391 Ajout hashage passwords (login+register fonctionnels)
1 year ago
Alix JEUDI--LEMOINE 44297309ad Ajout dépendance pour sha256
1 year ago
Alix JEUDI--LEMOINE 1cacded1ff Ajout findUserById + correction exception
1 year ago
Alix JEUDI--LEMOINE 74e8f223b3 Ajout message + id
1 year ago
Alix JEUDI--LEMOINE ebb8b7099f Correction type pour être plus générique (comme ça String + int passent)
1 year ago
Alix JEUDI--LEMOINE 649399b67d Ajout recherche utilisateur par ID
1 year ago
Alix JEUDI--LEMOINE 5e6a4d2cfc Commentaire inutile
1 year ago
Victor SOULIER 46dbcb1700 Merge branch 'master' into Springboot
1 year ago
Victor SOULIER ff90366211 suppression todo resolu
1 year ago
Victor SOULIER c7dc1447d5 ajout dto en vue du patch de scientifique
1 year ago
Victor SOULIER 1c8b8605f9 support patch thematiques/{id}
1 year ago
Victor SOULIER 368d1bda0c suppression import inutilisé
1 year ago
Victor SOULIER ba7c865f57 suppression interfaces pour les services (inutiles car 1 interface = 1 service
1 year ago
Alix JEUDI--LEMOINE 3601fe5523 Suppression partie dans UtilisateurWithPasswordDTO car il ne doit pas y être
1 year ago
Alix JEUDI--LEMOINE 73498838a5 Ajout @AllArgsConstructor (oublié précédemment) et passage au mdp en clair pour les tests car suppression Spring Security
1 year ago
Alix JEUDI--LEMOINE d8a920bf08 Suppression de partie dans UtilisateurDTO (partie est dans Joueur)
1 year ago
Alix JEUDI--LEMOINE c9cc4df4bd Corrections body request et types mime
1 year ago
Alix JEUDI--LEMOINE d903bf5d6d Pour plus tard si ajout de spring security
1 year ago
Alix JEUDI--LEMOINE 192d07667d Suppression de spring-boot-starter-security (cause des soucis au niveau des requêtes autres que GET, à voir plus tard)
1 year ago
Alix JEUDI--LEMOINE 1415cdc4b8 Ajout spring-boot-starter-security aux dépendances, à voir plus tard si vraiment utile, permet d'utiliser BCrypt pour les mots de passes (utilisé dans UtilisateurService)
1 year ago
Alix JEUDI--LEMOINE df2cec3e08 Ajout UtilisateurNotFoundException
1 year ago
Alix JEUDI--LEMOINE 207e529c8c Ajout UtilisateurController (login + register pour l'instant)
1 year ago
Alix JEUDI--LEMOINE 51f0799f86 Ajout findByEmail dans userrepo
1 year ago
Alix JEUDI--LEMOINE 1f6e3dd979 Ajout interface + service utilisateur
1 year ago
Alix JEUDI--LEMOINE e9c5b9e110 Ajout exception mot de passe incorrect
1 year ago
Alix JEUDI--LEMOINE df08e97866 Passage taille pages à 2
1 year ago
Alix JEUDI--LEMOINE 129338ec9c Correction warnings
1 year ago
Alix JEUDI--LEMOINE c2f6ac474d Correction faute Exception thematique
1 year ago
Alix JEUDI--LEMOINE 431288aac7 Ajout ReponseSimpleDTO
1 year ago
Alix JEUDI--LEMOINE 3b97f4b2ba Optimize imports
1 year ago
Alix JEUDI--LEMOINE 109eabf7b9 Ajout Scientifique à l'entité Reponse pour faire la liaison dans la Query
1 year ago
Alix JEUDI--LEMOINE bc9aa85119 Ajout recherche en DB des questions par scientifique (query à la main car réussi à faire en auto)
1 year ago
Alix JEUDI--LEMOINE 0c81de0d4a Changement de DTO pour réponse
1 year ago
Alix JEUDI--LEMOINE a5e361ffa2 Ajout filtre Scientifique au getAllQuestions
1 year ago
Alix JEUDI--LEMOINE 0df3390fd0 Ajout recherche avec critère au QuestionService
1 year ago
Alix JEUDI--LEMOINE ac45248509 Suppression use repo inutile
1 year ago
Alix JEUDI--LEMOINE e9a6768341 Modification filtres (utilisation de null par défaut au lieu de -1)
1 year ago
Alix JEUDI--LEMOINE 9a451618bd Modification commentaires + suppresssions quelques lignes
1 year ago
Alix JEUDI--LEMOINE fc555b98a9 Suppression base class Controller (inutile avec les Assembler)
1 year ago
Alix JEUDI--LEMOINE 1d10cab7e6 Modification des @ pour enlever warnings
1 year ago
Victor SOULIER 56be28929f debut implementation patch
1 year ago
Victor SOULIER 5b8a412a0d fix create
1 year ago
Victor SOULIER fd260b863d fix dto utilisé
1 year ago
Victor SOULIER 81a33c9460 jour 5 -- début journée
1 year ago
Victor SOULIER 488d30a41c Changes by Alix fix dto utilisé
1 year ago
Victor SOULIER 7a5b96c6d1 fix dto utilisé
1 year ago
Victor SOULIER 8347cd163e jour 4 -- fin de journée
1 year ago
Victor SOULIER 0b9c48be47 création d'un package par entitéDTO en vu de l'ajout de nouveaux plus restrictifs
1 year ago
Alix JEUDI--LEMOINE 700112823e Modifications aprèm J4
1 year ago
Alix JEUDI--LEMOINE 8826093d91 Modification constructeur
1 year ago
Alix JEUDI--LEMOINE 4994b319e3 Ajout pagination + DTO sur Difficulte
1 year ago
Alix JEUDI--LEMOINE 14cdefe3ad Ajout ratio aux scientifiques + correction types dans les classes pour lecture
1 year ago
Victor SOULIER 54f7d242c1 ajout DTO
1 year ago
Victor SOULIER a2fe781a96 jour 4 -- après-midi
1 year ago
Alix JEUDI--LEMOINE 0b22f02742 Travail jour 4 - pause midi -
1 year ago
Alix JEUDI--LEMOINE 790b121a57 Travail jour 3
1 year ago
Victor SOULIER d600565838 ajout application filter
1 year ago
Victor SOULIER 5bd5393612 Jour 3 -- Soir
1 year ago
Alix JEUDI--LEMOINE d284ee23fa Jour 3 - pause midi -
1 year ago
Victor SOULIER 37ac092c55 suppression AutoWired
1 year ago
Victor SOULIER 91cca9e810 ajout service thematique et route patch
1 year ago
Victor SOULIER b73afa868b ajustement nom exception
1 year ago
Victor SOULIER fb4fe8f283 ajustement nom exception
1 year ago
Victor SOULIER 67b640d806 ajout méthode existsByLibelle pour thematique
1 year ago
Victor SOULIER 9c809a024f suppression import inutilisé
1 year ago
Victor SOULIER 0ce38060ed erreur si données non attendu lors de la serialisation
1 year ago
Alix JEUDI--LEMOINE 600945bb16 Jour 2
1 year ago
Victor SOULIER 67ad1764a7 fix host
1 year ago
Victor SOULIER e996a853a3 passage en java 21
1 year ago
Victor SOULIER bb28a9aab3 ajout docker-compose : db + adminer
1 year ago
Victor SOULIER 15b4f3c79c Merge remote-tracking branch 'origin/Springboot' into Springboot
1 year ago
Victor SOULIER 0f8fa86fab fix java version
1 year ago
Alix JEUDI--LEMOINE f8ee356681 Modifications jour 2 - encore en cours-
1 year ago
Alix JEUDI--LEMOINE 5ee71a4538 Travail groupe API journée 1
1 year ago
Victor SOULIER f05e64d724 Merge branch 'Springboot' of codefirst.iut.uca.fr:tom.biard/ScienceQuest into Springboot
1 year ago
Alix JEUDI--LEMOINE dc91f93702 Déplacement
1 year ago
Alix JEUDI--LEMOINE 091758ca57 Déplacement dossier
1 year ago
Alix JEUDI--LEMOINE ed86ffcf9e Ajout base projet
1 year ago
Alix JEUDI--LEMOINE ef16b3ebec Déplacement
1 year ago
Alix JEUDI--LEMOINE 3bc78aa907 Déplacement dossier
1 year ago
Alix JEUDI--LEMOINE aec2bcc8d6 Ajout base projet
1 year ago

@ -0,0 +1,84 @@
kind: pipeline
type: docker
name: ScienceQuestAPI
trigger:
branch:
- Springboot
event:
- push
steps:
- name: deploy-container-postgresql
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: postgres:16-alpine
CONTAINERNAME: postgres_server
COMMAND: create
OVERWRITE: true
PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_PASSWORD:
from_secret: postgres_password_secret
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB: ScienceQuest
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER: ScienceQuest
ADMINS: alixjeudi--lemoine,victorsoulier,gwenaelplanchon
- name: build-app
image: maven:3-eclipse-temurin-21-alpine
depends_on: [deploy-container-postgresql]
commands:
- cd SpringBootProject/
- sed -i -e "s/localhost/tombiard-postgres_server/g" src/main/resources/application.properties
- echo -e "\nserver.port=443\nserver.forward-headers-strategy=framework" >> src/main/resources/application.properties
- mvn clean package
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://tombiard-postgres_server:5432/ScienceQuest
SPRING_DATASOURCE_USERNAME: ScienceQuest
SPRING_DATASOURCE_PASSWORD:
from_secret: postgres_password_secret
# - name: deploy-container-adminer
# image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
# environment:
# IMAGENAME: adminer:latest
# CONTAINERNAME: adminer
# COMMAND: create
# OVERWRITE: true
# CODEFIRST_CLIENTDRONE_ENV_ADMINER_DEFAULT_SERVER: postgres_server
# ADMINS: alixjeudi--lemoine,victorsoulier,gwenaelplanchon
- name: build-container-app-image
image: plugins/docker
depends_on: [build-app]
settings:
dockerfile: Dockerfile
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/alix.jeudi--lemoine/api
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
- name: deploy-container-app
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
depends_on: [build-container-app-image,deploy-container-postgresql]
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/alix.jeudi--lemoine/api:latest
CONTAINERNAME: api
COMMAND: create
OVERWRITE: true
CODEFIRST_CLIENTDRONE_ENV_SPRING_DATASOURCE_URL: jdbc:postgresql://tombiard-postgres_server:5432/ScienceQuest
CODEFIRST_CLIENTDRONE_ENV_SPRING_DATASOURCE_USERNAME: ScienceQuest
CODEFIRST_CLIENTDRONE_ENV_SPRING_DATASOURCE_PASSWORD:
from_secret: postgres_password_secret
ADMINS: alixjeudi--lemoine,victorsoulier,gwenaelplanchon
- name: code-analysis-api
image: aosapps/drone-sonar-plugin
depends_on: [deploy-container-app]
settings:
sonar_host:
from_secret: sonar_host
sonar_token:
from_secret: sonar_sae_token
exclusions: "**.java"

@ -0,0 +1,5 @@
FROM openjdk:21-slim
EXPOSE 443
WORKDIR /app
COPY "SpringBootProject/target/sae-0.0.1-SNAPSHOT.jar" "/app/sae-0.0.1-SNAPSHOT.jar"
CMD ["java", "-jar", "sae-0.0.1-SNAPSHOT.jar"]

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

@ -1,73 +0,0 @@
```plantuml
@startwbs
<style>
wbsDiagram {
.blue {
BackgroundColor lightblue
}
.green {
BackgroundColor lightgreen
}
.yellow {
BackgroundColor #ffbf87
}
.orange {
BackgroundColor lightyellow
}
.red {
BackgroundColor #FFB2B2
}
.pink {
BackgroundColor #ff99ee
}
.purple {
BackgroundColor #cfb3ff
}
}
</style>
* Projet "Science Quest" <<blue>>
** Établir la conception <<green>>
*** Créer le site Web <<yellow>>
**** Conception des mini-jeux <<orange>>
***** Conception du jeu "Qui-est-ce ?" <<red>>
***** Conception du jeu "Quizz" <<red>>
***** Conception du jeu "Pendu" <<red>>
*** Créer l'application Mobile <<yellow>>
**** Conception des mini-jeux <<orange>>
***** Conception du jeu "Qui-est-ce ?" <<red>>
***** Conception du jeu "Quizz" <<red>>
***** Conception du jeu "Pendu" <<red>>
** Démarrer le développement <<green>>
*** Développer le site Web <<yellow>>
**** Développement des mini-jeux <<orange>>
***** Développement du jeu "Qui-est-ce ?" <<red>>
***** Développement du jeu "Quizz" <<red>>
***** Développement du jeu "Pendu" <<red>>
*** Développer l'application Mobile <<yellow>>
**** Développement des mini-jeux <<orange>>
***** Développement du jeu "Qui-est-ce ?" <<red>>
***** Développement du jeu "Quizz" <<red>>
***** Développement du jeu "Pendu" <<red>>
** Tester l'application <<green>>
*** Tester le site Web <<yellow>>
**** Test des mini-jeux <<orange>>
***** Test du jeu "Qui-est-ce ?" <<red>>
***** Test du jeu "Quizz" <<red>>
***** Test du jeu "Pendu" <<red>>
*** Tester l'application Mobile <<yellow>>
**** Test des mini-jeux <<orange>>
***** Test du jeu "Qui-est-ce ?" <<red>>
***** Test du jeu "Quizz" <<red>>
***** Test du jeu "Pendu" <<red>>
** Création des livrables <<pink>>
*** Application client web <<purple>>
*** Application client mobile <<purple>>
*** Application admin web <<purple>>
*** Application app monitoring web <<purple>>
*** Conception et contenu de la base de données <<purple>>
*** Installation dun pare-feu <<purple>>
*** Installation dun service web <<purple>>
*** Installation dun SGBD <<purple>>
*** Installation des serveurs pour les services nommées ci-dessus et configurations <<purple>>
@endwbs

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

@ -0,0 +1,24 @@
version: '3.9'
services:
postgres_server:
image: postgres:16-alpine
container_name: postgres_server
restart: unless-stopped
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: 94gg98mFnp269JY98P2pZtVnEd8UkWPm
POSTGRES_USER: ScienceQuest
POSTGRES_DB: ScienceQuest
adminer:
image: adminer
depends_on: [postgres_server]
restart: unless-stopped
environment:
ADMINER_DEFAULT_SERVER: postgres_server
ports:
- "8081:8080"

@ -0,0 +1,308 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.2.0
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "$(uname)" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
else
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=$(which readlink)
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
if $darwin ; then
javaHome="$(dirname "\"$javaExecutable\"")"
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
else
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
fi
javaHome="$(dirname "\"$javaExecutable\"")"
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=$(cd "$wdir/.." || exit 1; pwd)
fi
# end of workaround
done
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
# Remove \r in case we run on Windows within Git Bash
# and check out the repository with auto CRLF management
# enabled. Otherwise, we may read lines that are delimited with
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
# splitting rules.
tr -s '\r\n' ' ' < "$1"
fi
}
log() {
if [ "$MVNW_VERBOSE" = true ]; then
printf '%s\n' "$1"
fi
}
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
log "$MAVEN_PROJECTBASEDIR"
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
if [ -r "$wrapperJarPath" ]; then
log "Found $wrapperJarPath"
else
log "Couldn't find $wrapperJarPath, downloading it ..."
if [ -n "$MVNW_REPOURL" ]; then
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
else
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
fi
while IFS="=" read -r key value; do
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
safeValue=$(echo "$value" | tr -d '\r')
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
log "Downloading from: $wrapperUrl"
if $cygwin; then
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget > /dev/null; then
log "Found wget ... using wget"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
log "Found curl ... using curl"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
else
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
fi
else
log "Falling back to using Java to download"
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaSource=$(cygpath --path --windows "$javaSource")
javaClass=$(cygpath --path --windows "$javaClass")
fi
if [ -e "$javaSource" ]; then
if [ ! -e "$javaClass" ]; then
log " - Compiling MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/javac" "$javaSource")
fi
if [ -e "$javaClass" ]; then
log " - Running MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
wrapperSha256Sum=""
while IFS="=" read -r key value; do
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
if [ -n "$wrapperSha256Sum" ]; then
wrapperSha256Result=false
if command -v sha256sum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
elif command -v shasum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
exit 1
fi
if [ $wrapperSha256Result = false ]; then
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
exit 1
fi
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
# shellcheck disable=SC2086 # safe args
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

@ -0,0 +1,205 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.2.0
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
SET WRAPPER_SHA_256_SUM=""
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
)
IF NOT %WRAPPER_SHA_256_SUM%=="" (
powershell -Command "&{"^
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
" exit 1;"^
"}"^
"}"
if ERRORLEVEL 1 goto error
)
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%

@ -0,0 +1,82 @@
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>fr.iut.sciencequest</groupId>
<artifactId>sae</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sae</name>
<description>API SAE ScienceQuest</description>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.16.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,28 @@
package fr.iut.sciencequest.sae;
import org.modelmapper.ModelMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.accept.FixedContentNegotiationStrategy;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
@Configuration
public class ApplicationConfig implements WebMvcConfigurer {
public static final int DEFAULT_PAGEABLE_SIZE = 2;
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
// Permet de forcer l'affichage des erreurs en JSON sans prendre en compte les headers du client
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.strategies(List.of(new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON)));
}
}

@ -0,0 +1,70 @@
package fr.iut.sciencequest.sae;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingResponseWrapper;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@Component
@Order(1)
public class ApplicationFilter extends OncePerRequestFilter {
private final ObjectMapper objectMapper;
public ApplicationFilter(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
@Override
@NonNull
protected void doFilterInternal(@Nullable HttpServletRequest request, @Nullable HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
// Intercept and modify the JSON response
assert response != null;
ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
filterChain.doFilter(request, responseWrapper);
if (responseWrapper.getContentType() != null && responseWrapper.getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)) {
try {
// Parse JSON
JsonNode root = objectMapper.readTree(new String(responseWrapper.getContentAsByteArray(), StandardCharsets.UTF_8));
// Vérification de l'existance du node _embedded && s'il contient un node enfant
JsonNode embeddedNode = root.get("_embedded");
if (embeddedNode != null && embeddedNode.isObject() && embeddedNode.size() == 1) {
JsonNode subNode = embeddedNode.elements().next(); // Récupération node enfant
if (subNode != null && subNode.isArray()) {
ArrayNode subNodeArr = (ArrayNode) subNode;
// Correction de la profondeur
((ObjectNode) root).remove("_embedded");
((ObjectNode) root).set("_embedded", subNodeArr);
}
}
// Retour du JSON dans l'objectMapper en String
String modifiedResponseBody = objectMapper.writeValueAsString(root);
// Ecriture du JSON dans la réponse
response.setCharacterEncoding("UTF-8");
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.getOutputStream().write(modifiedResponseBody.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) { System.err.println("ApplicationFilter (_embedded) : " + e.getMessage()); }
}
}
}

@ -0,0 +1,27 @@
package fr.iut.sciencequest.sae;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@SpringBootApplication
public class SaeApplication {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
@NonNull
public void addCorsMappings(@Nullable CorsRegistry registry) {
assert registry != null;
registry.addMapping("/**").allowedOrigins("*");
}
};
}
public static void main(String[] args) {
SpringApplication.run(SaeApplication.class, args);
}
}

@ -0,0 +1,20 @@
package fr.iut.sciencequest.sae;
/*
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
return http.build();
}
@Bean
public PasswordEncoder encoder() {
return new BCryptPasswordEncoder();
}
}*/

@ -0,0 +1,26 @@
package fr.iut.sciencequest.sae.assemblers;
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteDTO;
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
import fr.iut.sciencequest.sae.entities.Difficulte;
import jakarta.annotation.Nullable;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
@Component
public class DifficulteModelAssembler extends RepresentationModelAssemblerSupport<Difficulte, DifficulteSimpleDTO> {
public DifficulteModelAssembler() {
super(Difficulte.class, DifficulteSimpleDTO.class);
}
@Override
@NonNull
public DifficulteSimpleDTO toModel(@Nullable Difficulte entity) {
ModelMapper mapper = new ModelMapper();
return mapper.map(entity, DifficulteSimpleDTO.class);
}
}

@ -0,0 +1,42 @@
package fr.iut.sciencequest.sae.assemblers;
import fr.iut.sciencequest.sae.controllers.ScientifiqueController;
import org.springframework.hateoas.CollectionModel;
import fr.iut.sciencequest.sae.dto.indice.IndiceSimpleWithScientifiquesIdDTO;
import fr.iut.sciencequest.sae.entities.Indice;
import jakarta.annotation.Nullable;
import org.modelmapper.ModelMapper;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
@Component
public class IndiceModelAssembler extends RepresentationModelAssemblerSupport<Indice, IndiceSimpleWithScientifiquesIdDTO> {
public IndiceModelAssembler() {
super(Indice.class, IndiceSimpleWithScientifiquesIdDTO.class);
}
@Override
@NonNull
public IndiceSimpleWithScientifiquesIdDTO toModel(@Nullable Indice entity) {
ModelMapper mapper = new ModelMapper();
return mapper.map(entity, IndiceSimpleWithScientifiquesIdDTO.class);
}
@Override
@NonNull
public CollectionModel<IndiceSimpleWithScientifiquesIdDTO> toCollectionModel(@Nullable Iterable<? extends Indice> entities) {
assert entities != null;
CollectionModel<IndiceSimpleWithScientifiquesIdDTO> collectionModel = super.toCollectionModel(entities);
// Le lien n'est pas ajouté automatiquement si l'on utilise pas la pagination /!\
if(collectionModel.iterator().hasNext())
collectionModel.add(linkTo(methodOn(ScientifiqueController.class).getScientistHints(collectionModel.iterator().next().getScientifique().getId())).withSelfRel());
return collectionModel;
}
}

@ -0,0 +1,25 @@
package fr.iut.sciencequest.sae.assemblers;
import fr.iut.sciencequest.sae.controllers.PartieKahootController;
import fr.iut.sciencequest.sae.entities.Partie;
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
import jakarta.annotation.Nullable;
import org.modelmapper.ModelMapper;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
@Component
public class PartieModelAssembler extends RepresentationModelAssemblerSupport<Partie, PartieDTO> {
public PartieModelAssembler() {
super(PartieKahootController.class, PartieDTO.class);
}
@Override
@NonNull
public PartieDTO toModel(@Nullable Partie entity) {
ModelMapper mapper = new ModelMapper();
return mapper.map(entity, PartieDTO.class);
}
}

@ -0,0 +1,25 @@
package fr.iut.sciencequest.sae.assemblers;
import fr.iut.sciencequest.sae.controllers.QuestionController;
import fr.iut.sciencequest.sae.entities.Question;
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
import jakarta.annotation.Nullable;
import org.modelmapper.ModelMapper;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
@Component
public class QuestionModelAssembler extends RepresentationModelAssemblerSupport<Question, QuestionDTO> {
public QuestionModelAssembler() {
super(QuestionController.class, QuestionDTO.class);
}
@Override
@NonNull
public QuestionDTO toModel(@Nullable Question entity) {
ModelMapper mapper = new ModelMapper();
return mapper.map(entity, QuestionDTO.class);
}
}

@ -0,0 +1,30 @@
package fr.iut.sciencequest.sae.assemblers;
import fr.iut.sciencequest.sae.controllers.ScientifiqueController;
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueDTO;
import fr.iut.sciencequest.sae.entities.Scientifique;
import jakarta.annotation.Nullable;
import org.modelmapper.ModelMapper;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
@Component
public class ScientifiqueModelAssembler extends RepresentationModelAssemblerSupport<Scientifique, ScientifiqueDTO> {
public ScientifiqueModelAssembler() {
super(ScientifiqueController.class, ScientifiqueDTO.class);
}
@Override
@NonNull
public ScientifiqueDTO toModel(@Nullable Scientifique entity) {
ModelMapper mapper = new ModelMapper();
ScientifiqueDTO scientifiqueDTO = mapper.map(entity, ScientifiqueDTO.class);
scientifiqueDTO.add(linkTo(methodOn(ScientifiqueController.class).getScientistHints(scientifiqueDTO.getId())).withRel("indices"));
scientifiqueDTO.add(linkTo(methodOn(ScientifiqueController.class).getScientistById(scientifiqueDTO.getId())).withSelfRel());
return scientifiqueDTO;
}
}

@ -0,0 +1,23 @@
package fr.iut.sciencequest.sae.assemblers;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueDTO;
import fr.iut.sciencequest.sae.entities.Thematique;
import jakarta.annotation.Nullable;
import org.modelmapper.ModelMapper;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
@Component
public class ThematiqueModelAssembler extends RepresentationModelAssemblerSupport<Thematique, ThematiqueDTO> {
public ThematiqueModelAssembler() {
super(Thematique.class, ThematiqueDTO.class);
}
@Override
@NonNull
public ThematiqueDTO toModel(@Nullable Thematique entity) {
ModelMapper mapper = new ModelMapper();
return mapper.map(entity, ThematiqueDTO.class);
}
}

@ -0,0 +1,23 @@
package fr.iut.sciencequest.sae.assemblers;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
import fr.iut.sciencequest.sae.entities.Thematique;
import jakarta.annotation.Nullable;
import org.modelmapper.ModelMapper;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
@Component
public class ThematiqueSimpleModelAssembler extends RepresentationModelAssemblerSupport<Thematique, ThematiqueSimpleDTO> {
public ThematiqueSimpleModelAssembler() {
super(Thematique.class, ThematiqueSimpleDTO.class);
}
@Override
@NonNull
public ThematiqueSimpleDTO toModel(@Nullable Thematique entity) {
ModelMapper mapper = new ModelMapper();
return mapper.map(entity, ThematiqueSimpleDTO.class);
}
}

@ -0,0 +1,38 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.ApplicationConfig;
import fr.iut.sciencequest.sae.assemblers.DifficulteModelAssembler;
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
import fr.iut.sciencequest.sae.entities.Difficulte;
import fr.iut.sciencequest.sae.services.DifficulteService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.PagedModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/difficultes")
public class DifficulteController {
private final DifficulteModelAssembler difficulteModelAssembler;
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
private final PagedResourcesAssembler<Difficulte> pagedResourcesAssembler;
public final DifficulteService difficulteService;
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PagedModel<DifficulteSimpleDTO> getAllDifficultes(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p) {
Page<Difficulte> difficultePage = this.difficulteService.findAll(p);
return pagedResourcesAssembler.toModel(difficultePage, difficulteModelAssembler);
}
}

@ -0,0 +1,42 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.dto.indice.IndiceDTO;
import fr.iut.sciencequest.sae.dto.indice.IndiceSimpleWithScientifiquesIdDTO;
import fr.iut.sciencequest.sae.dto.indice.IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO;
import fr.iut.sciencequest.sae.entities.Indice;
import fr.iut.sciencequest.sae.services.IndiceService;
import jakarta.validation.Valid;
import jakarta.validation.Validator;
import lombok.AllArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.beanvalidation.SpringValidatorAdapter;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/indices")
public class IndiceController {
private final IndiceService indiceService;
private final ModelMapper modelMapper;
private final Validator validator;
@PatchMapping(value="/{id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public IndiceSimpleWithScientifiquesIdDTO patchIndice(@PathVariable("id") int id, @RequestBody @Valid IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO indicePartial) throws NoSuchMethodException, MethodArgumentNotValidException {
IndiceDTO indicedto = this.modelMapper.map(indicePartial, IndiceDTO.class);
indicedto.setId(id);
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(indicedto, "indice");;
SpringValidatorAdapter adapter = new SpringValidatorAdapter(this.validator);
adapter.validate(indicedto, errors);
if(errors.hasErrors()){
throw new MethodArgumentNotValidException(null, errors); }
Indice indice = this.modelMapper.map(indicedto, Indice.class);
return this.modelMapper.map(this.indiceService.update(indice), IndiceSimpleWithScientifiquesIdDTO.class);
}
}

@ -0,0 +1,43 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.dto.invite.InviteSimpleDTO;
import fr.iut.sciencequest.sae.dto.invite.InviteWithPseudoOnlyDTO;
import fr.iut.sciencequest.sae.entities.Invite;
import fr.iut.sciencequest.sae.services.InviteService;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import static org.springframework.data.jpa.domain.AbstractPersistable_.id;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/invite")
public class InviteController {
private final InviteService inviteService;
private final ModelMapper modelMapper;
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public InviteSimpleDTO createInvite(@RequestBody @Valid InviteWithPseudoOnlyDTO inviteRequest){
Invite invite = this.modelMapper.map(inviteRequest, Invite.class);
return this.modelMapper.map(this.inviteService.create(invite), InviteSimpleDTO.class);
}
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public InviteSimpleDTO getInvite(@PathVariable int id){
return this.modelMapper.map(this.inviteService.findById(id), InviteSimpleDTO.class);
}
@PatchMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public InviteSimpleDTO updateInvite(@PathVariable int id, @RequestBody @Valid InviteWithPseudoOnlyDTO updatedInvite){
Invite invite = this.inviteService.findById(id);
invite.setPseudo(updatedInvite.getPseudo());
return this.modelMapper.map(this.inviteService.update(invite), InviteSimpleDTO.class);
}
}

@ -0,0 +1,39 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.dto.jeu.JeuDTO;
import fr.iut.sciencequest.sae.entities.Jeu;
import fr.iut.sciencequest.sae.exceptions.notFound.JeuNotFoundException;
import fr.iut.sciencequest.sae.repositories.JeuRepository;
import lombok.AllArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/jeux")
public class JeuController {
private final JeuRepository jeuRepository;
private final ModelMapper modelMapper;
@RequestMapping(value = "/{id}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Jeu getJeu(@PathVariable int id) {
return this.jeuRepository.findById(id).orElseThrow(() -> new JeuNotFoundException(id));
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public Iterable<JeuDTO> getJeux() {
List<JeuDTO> jeuDTOList = new ArrayList<>();
for(Jeu jeu : this.jeuRepository.findAll()) {
jeuDTOList.add(this.modelMapper.map(jeu, JeuDTO.class).add(
linkTo(JeuController.class).slash(jeu.getId()).withRel("self")
));
}
return jeuDTOList;
}
}

@ -0,0 +1,195 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.controllers.request.PartieAddJoueurRequest;
import fr.iut.sciencequest.sae.controllers.request.PartieReponse;
import fr.iut.sciencequest.sae.controllers.request.PartieRequest;
import fr.iut.sciencequest.sae.dto.partieKahoot.PartieKahootDTO;
import fr.iut.sciencequest.sae.dto.partieKahoot.PartieKahootQuestionDTO;
import fr.iut.sciencequest.sae.dto.partieKahoot.PartieKahootStatusDTO;
import fr.iut.sciencequest.sae.dto.reponse.ReponseValideDTO;
import fr.iut.sciencequest.sae.entities.*;
import fr.iut.sciencequest.sae.exceptions.notFound.ScorePartieKahootJoueurNotFound;
import fr.iut.sciencequest.sae.exceptions.partie.*;
import fr.iut.sciencequest.sae.repositories.QuestionPartieKahootRepository;
import fr.iut.sciencequest.sae.repositories.ReponsePartieKahootRepository;
import fr.iut.sciencequest.sae.repositories.ScorePartieKahootJoueurRepository;
import fr.iut.sciencequest.sae.services.*;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/partie/kahoot")
public class PartieKahootController {
private static final int NOMBRE_QUESTION = 2;
private final QuestionPartieKahootRepository questionPartieKahootRepository;
private final ScorePartieKahootJoueurRepository scorePartieKahootJoueurRepository;
private final PartieKahootService partieKahootService;
private final JoueurService joueurService;
private final QuestionService questionService;
private final ReponseService reponseService;
private final ThematiqueService thematiqueService;
private final DifficulteService difficulteService;
private final ModelMapper modelMapper;
private final ReponsePartieKahootRepository reponsePartieKahootRepository;
@RequestMapping(value = "/{codeInvitation}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public PartieKahootDTO getPartie(@PathVariable String codeInvitation) {
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
return this.modelMapper.map(partieKahoot, PartieKahootDTO.class);
}
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public PartieKahootDTO createPartie(@RequestBody @Valid PartieRequest request) {
PartieKahoot partie = new PartieKahoot();
Joueur joueur = this.joueurService.findById(request.getIdJoueur());
partie.setJoueurs(List.of(joueur));
partie.setThematiques(new ArrayList<>());
for(int idThematique: request.getThematiques()){
partie.getThematiques().add(this.thematiqueService.findById(idThematique));
}
partie.setDifficulte(this.difficulteService.findById(request.getIdDifficulte()));
partie = this.partieKahootService.create(partie);
//setup score
ScorePartieKahootJoueur score = new ScorePartieKahootJoueur();
score.setId(new ScorePartieKahootJoueurKey(joueur.getId(), partie.getId()));
score.setJoueur(joueur);
score.setPartie(partie);
this.scorePartieKahootJoueurRepository.save(score);
//setup question
List<Question> questions = this.questionService.getRandomQuestions(NOMBRE_QUESTION, partie.getThematiques(), partie.getDifficulte());
for(Question question: questions){
QuestionPartieKahoot questionPartie = new QuestionPartieKahoot();
questionPartie.setId(new QuestionPartieKahootKey(question.getId(), partie.getId()));
questionPartie.setQuestion(question);
questionPartie.setPartie(partie);
this.questionPartieKahootRepository.save(questionPartie);
}
partie = this.partieKahootService.findById(partie.getId());
return this.modelMapper.map(partie, PartieKahootDTO.class);
}
@PostMapping(value= "/{codeInvitation}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PartieKahootDTO addPlayerToPartie(@PathVariable String codeInvitation, @RequestBody @Valid PartieAddJoueurRequest request){
Joueur joueur = this.joueurService.findById(request.getIdJoueur());
PartieKahoot partie = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
if(!partie.getStatus().equals(Status.Pending)) throw new PartyAlreadyStartedException();
if(!partie.getJoueurs().stream().anyMatch(j -> j.getId() == joueur.getId())){
ScorePartieKahootJoueur score = new ScorePartieKahootJoueur();
score.setId(new ScorePartieKahootJoueurKey(joueur.getId(), partie.getId()));
score.setJoueur(joueur);
score.setPartie(partie);
partie.getScores().add(score);
partie.getJoueurs().add(joueur);
this.scorePartieKahootJoueurRepository.save(score);
}
return this.modelMapper.map(this.partieKahootService.update(partie), PartieKahootDTO.class);
}
@PostMapping(value = "/{codeInvitation}/demarrer", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PartieKahootStatusDTO demarrerPartie(@PathVariable String codeInvitation){
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
if(partieKahoot.getStatus() == Status.Started || partieKahoot.getStatus() == Status.DisplayingScore){
throw new PartyAlreadyStartedException();
}
partieKahoot.setStatus(Status.Started);
partieKahoot = this.partieKahootService.questionSuivante(partieKahoot);
return this.modelMapper.map(partieKahoot, PartieKahootStatusDTO.class);
}
@GetMapping(value = "/{codeInvitation}/status", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PartieKahootStatusDTO getStatusPartie(@PathVariable String codeInvitation){
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
return this.modelMapper.map(partieKahoot, PartieKahootStatusDTO.class);
}
@GetMapping(value = "/{codeInvitation}/question", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PartieKahootQuestionDTO getQuestionActuel(@PathVariable String codeInvitation){
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
if(partieKahoot.getStatus() == Status.Pending){
throw new PartyNotStartedException();
}
if(partieKahoot.getStatus() == Status.Ended){
throw new PartyIsEndedException();
}
return this.modelMapper.map(partieKahoot, PartieKahootQuestionDTO.class);
}
@PostMapping(value = "/{codeInvitation}/reponse", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public ReponseValideDTO repondre(@PathVariable String codeInvitation, @RequestBody @Valid PartieReponse request){
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
Joueur joueur = this.joueurService.findById(request.getIdJoueur());
if(partieKahoot.getStatus() == Status.Pending){
throw new PartyNotStartedException();
}
if(partieKahoot.getStatus() == Status.Ended){
throw new PartyIsEndedException();
}
if(partieKahoot.getJoueurs().stream().noneMatch(joueur1 -> Objects.equals(joueur1.getId(), joueur.getId()))){
throw new JoueurPasDansPartieException();
}
Question questionActuel = partieKahoot.getQuestionActuel();
if(partieKahoot.getReponses().stream()
.filter(partieReponse -> Objects.equals(partieReponse.getJoueur().getId(), joueur.getId()))
.anyMatch(partieReponse -> Objects.equals(partieReponse.getQuestion().getId(), questionActuel.getId()))){
throw new QuestionDejaReponduException();
}
Reponse reponse = reponseService.findById(request.getIdReponse());
if(!Objects.equals(reponse.getQuestion().getId(), partieKahoot.getQuestionActuel().getId())){
throw new ReponseIncoherenteException();
}
Calendar actualDate = Calendar.getInstance();
actualDate.setTime(new Date());
if(actualDate.after(partieKahoot.getTempsLimiteReponse())){
throw new ReponseTempsLimiteDepasseException();
}
ReponsePartieKahoot reponsePartie = new ReponsePartieKahoot();
reponsePartie.setId(new ReponsePartieKahootKey(reponse.getQuestion().getId(), partieKahoot.getId(), joueur.getId()));
reponsePartie.setQuestion(reponse.getQuestion());
reponsePartie.setPartie(partieKahoot);
reponsePartie.setReponse(reponse);
reponsePartie.setJoueur(joueur);
this.reponsePartieKahootRepository.save(reponsePartie);
ScorePartieKahootJoueur scorePartieKahootJoueur = partieKahoot.getScores().stream().filter(socre -> socre.getJoueur().getId() == joueur.getId())
.findFirst()
.orElseThrow(() -> new ScorePartieKahootJoueurNotFound(joueur.getId()));
scorePartieKahootJoueur.setScore(scorePartieKahootJoueur.getScore() + this.partieKahootService.getScore(partieKahoot.getTempsLimiteReponse(), reponse));
this.scorePartieKahootJoueurRepository.save(scorePartieKahootJoueur);
return this.modelMapper.map(reponse, ReponseValideDTO.class);
}
}

@ -0,0 +1,35 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.ApplicationConfig;
import fr.iut.sciencequest.sae.assemblers.QuestionModelAssembler;
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
import fr.iut.sciencequest.sae.entities.Question;
import fr.iut.sciencequest.sae.services.QuestionService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.PagedModel;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/questions")
public class QuestionController {
private final QuestionService questionService;
private final QuestionModelAssembler questionModelAssembler;
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
private final PagedResourcesAssembler<Question> pagedResourcesAssembler;
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public PagedModel<QuestionDTO> getAllQuestions(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p,
@RequestParam(value = "scientifiqueId", defaultValue = "") Integer scientifiqueId) {
Page<Question> questionPage = (scientifiqueId == null ? questionService.findAll(p) : questionService.findWithCriteria(p, scientifiqueId)); //TEMPORAIRE NE PAS ENLEVER
return pagedResourcesAssembler.toModel(questionPage, questionModelAssembler);
}
}

@ -0,0 +1,72 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.ApplicationConfig;
import fr.iut.sciencequest.sae.assemblers.IndiceModelAssembler;
import fr.iut.sciencequest.sae.assemblers.ScientifiqueModelAssembler;
import fr.iut.sciencequest.sae.dto.indice.IndiceLibelleOnlyDTO;
import fr.iut.sciencequest.sae.dto.indice.IndiceSimpleWithScientifiquesIdDTO;
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueDTO;
import fr.iut.sciencequest.sae.entities.Indice;
import fr.iut.sciencequest.sae.entities.Scientifique;
import fr.iut.sciencequest.sae.services.IndiceService;
import fr.iut.sciencequest.sae.services.ScientifiqueService;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.PagedModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/scientifiques")
public class ScientifiqueController {
private final ScientifiqueService scientifiqueService;
private final ScientifiqueModelAssembler scientifiqueModelAssembler;
private final IndiceModelAssembler indiceModelAssembler;
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
private final PagedResourcesAssembler<Scientifique> pagedResourcesAssembler;
private final IndiceService indiceService;
private final ModelMapper modelMapper;
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public PagedModel<ScientifiqueDTO> getAllScientists(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p,
@RequestParam(value = "thematiqueId", defaultValue = "") Integer thematiqueId,
@RequestParam(value = "difficulteId", defaultValue = "") Integer difficulteId) {
Page<Scientifique> page = (thematiqueId == null && difficulteId == null ? this.scientifiqueService.findAll(p) : this.scientifiqueService.findAllWithCriteria(p, thematiqueId, difficulteId));
return pagedResourcesAssembler.toModel(page, scientifiqueModelAssembler);
}
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ScientifiqueDTO getScientistById(@PathVariable Integer id) {
return scientifiqueModelAssembler.toModel(this.scientifiqueService.findById(id));
}
@GetMapping(value="/{id}/indices", produces = MediaType.APPLICATION_JSON_VALUE)
public CollectionModel<IndiceSimpleWithScientifiquesIdDTO> getScientistHints(@PathVariable Integer id) {
return indiceModelAssembler.toCollectionModel(this.scientifiqueService.getLinkedIndicesByScientifiqueId(id));
}
@PostMapping(value="/{id}/indices", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public IndiceSimpleWithScientifiquesIdDTO postIndice(@PathVariable Integer id, @Valid @RequestBody IndiceLibelleOnlyDTO indiceWithLibelleOnly) {
Indice indice = this.modelMapper.map(indiceWithLibelleOnly, Indice.class);
indice.setScientifique(this.scientifiqueService.findById(id));
return this.modelMapper.map(this.indiceService.create(indice), IndiceSimpleWithScientifiquesIdDTO.class);
}
@DeleteMapping(value="/{id}/indices/{indiceId}")
@ResponseStatus(HttpStatus.ACCEPTED)
public void deleteIndice(@PathVariable Integer id, @PathVariable Integer indiceId) {
this.indiceService.delete(indiceId);
}
}

@ -0,0 +1,57 @@
package fr.iut.sciencequest.sae.controllers;
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.iut.sciencequest.sae.ApplicationConfig;
import fr.iut.sciencequest.sae.assemblers.ThematiqueModelAssembler;
import fr.iut.sciencequest.sae.assemblers.ThematiqueSimpleModelAssembler;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueLibelleOnlyDTO;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
import fr.iut.sciencequest.sae.entities.Thematique;
import fr.iut.sciencequest.sae.services.ScientifiqueService;
import fr.iut.sciencequest.sae.services.ThematiqueService;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.PagedModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/thematiques")
public class ThematiqueController {
private final ThematiqueService thematiqueService;
private final ScientifiqueService scientifiqueService;
private final ThematiqueModelAssembler thematiqueModelAssembler;
private final ThematiqueSimpleModelAssembler thematiqueSimpleModelAssembler;
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
private final PagedResourcesAssembler<Thematique> pagedResourcesAssembler;
private final ModelMapper modelMapper;
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PagedModel<ThematiqueSimpleDTO> getAllThematiques(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p) {
return pagedResourcesAssembler.toModel(this.thematiqueService.findAll(p), thematiqueSimpleModelAssembler);
}
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public ThematiqueSimpleDTO createThematique(@Valid @RequestBody ThematiqueLibelleOnlyDTO thematique) {
return thematiqueSimpleModelAssembler.toModel(this.thematiqueService.create(this.modelMapper.map(thematique, Thematique.class)));
}
@PatchMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public ThematiqueSimpleDTO updateThematique(@PathVariable("id") int id, @Valid @RequestBody ThematiqueLibelleOnlyDTO partialThematique) {
Thematique dstThematique = this.thematiqueService.findById(id);
if(partialThematique.getLibelle() != null){
dstThematique.setLibelle(partialThematique.getLibelle());
}
return thematiqueSimpleModelAssembler.toModel(this.thematiqueService.update(dstThematique));
}
}

@ -0,0 +1,36 @@
package fr.iut.sciencequest.sae.controllers;
import fr.iut.sciencequest.sae.assemblers.ScientifiqueModelAssembler;
import fr.iut.sciencequest.sae.dto.utilisateur.UtilisateurDTO;
import fr.iut.sciencequest.sae.dto.utilisateur.UtilisateurWithPasswordDTO;
import fr.iut.sciencequest.sae.services.ScientifiqueService;
import fr.iut.sciencequest.sae.services.UtilisateurService;
import lombok.AllArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@AllArgsConstructor
@RestController
@RequestMapping("/api/v1/utilisateur")
public class UtilisateurController {
private final UtilisateurService utilisateurService;
private final ModelMapper modelMapper;
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public UtilisateurDTO register(@RequestBody UtilisateurWithPasswordDTO user) {
return utilisateurService.save(user);
}
@PostMapping(path = "/connexion", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public UtilisateurDTO login(@RequestBody UtilisateurWithPasswordDTO user) {
return utilisateurService.login(user);
}
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public UtilisateurDTO getUser(@PathVariable Integer id) {
return modelMapper.map(this.utilisateurService.findUserById(id), UtilisateurDTO.class);
}
}

@ -0,0 +1,12 @@
package fr.iut.sciencequest.sae.controllers.request;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Data
public class PartieAddJoueurRequest {
@NotNull
private int idJoueur;
}

@ -0,0 +1,14 @@
package fr.iut.sciencequest.sae.controllers.request;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Data
public class PartieReponse {
@NotNull
private int idReponse;
@NotNull
private int idJoueur;
}

@ -0,0 +1,19 @@
package fr.iut.sciencequest.sae.controllers.request;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Data
public class PartieRequest {
@NotNull
private int idJoueur;
@NotEmpty
private List<Integer> thematiques;
@NotNull
private Integer idDifficulte;
}

@ -0,0 +1,30 @@
package fr.iut.sciencequest.sae.dto.admin;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdminWithPasswordDTO extends RepresentationModel<AdminWithPasswordDTO> {
@NotNull
private Integer id;
@Email
@NotNull
@NotBlank
private String email;
@NotNull
@NotBlank
private String password;
}

@ -0,0 +1,24 @@
package fr.iut.sciencequest.sae.dto.difficulte;
import fr.iut.sciencequest.sae.entities.Scientifique;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class DifficulteDTO extends RepresentationModel<DifficulteDTO> {
@NotNull
private Integer id;
@NotBlank
private String libelle;
private Iterable<Scientifique> scientifiques;
}

@ -0,0 +1,17 @@
package fr.iut.sciencequest.sae.dto.difficulte;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class DifficulteIdOnlyDTO extends RepresentationModel<DifficulteIdOnlyDTO> {
@NotNull
private Integer id;
}

@ -0,0 +1,19 @@
package fr.iut.sciencequest.sae.dto.difficulte;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class DifficulteSimpleDTO extends RepresentationModel<DifficulteSimpleDTO> {
@NotNull
private Integer id;
@NotBlank
private String libelle;
}

@ -0,0 +1,27 @@
package fr.iut.sciencequest.sae.dto.indice;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueDTO;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class IndiceDTO extends RepresentationModel<IndiceDTO> {
@NotNull
private Integer id;
@NotBlank
private String libelle;
@NotNull
private ScientifiqueDTO scientifique;
}

@ -0,0 +1,18 @@
package fr.iut.sciencequest.sae.dto.indice;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class IndiceLibelleOnlyDTO extends RepresentationModel<IndiceLibelleOnlyDTO> {
@NotBlank
private String libelle;
}

@ -0,0 +1,25 @@
package fr.iut.sciencequest.sae.dto.indice;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueIdOnlyDTO;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class IndiceSimpleWithScientifiquesIdDTO extends RepresentationModel<IndiceSimpleWithScientifiquesIdDTO> {
@NotNull
private Integer id;
@NotBlank
private String libelle;
@NotNull
private ScientifiqueIdOnlyDTO scientifique;
}

@ -0,0 +1,22 @@
package fr.iut.sciencequest.sae.dto.indice;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueIdOnlyDTO;
import jakarta.validation.Valid;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO extends RepresentationModel<IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO> {
private String libelle;
@Valid
private ScientifiqueIdOnlyDTO scientifique;
}

@ -0,0 +1,26 @@
package fr.iut.sciencequest.sae.dto.invite;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class InviteDTO extends RepresentationModel<InviteDTO> {
@NotNull
private Integer id;
@NotBlank
private String pseudo;
private PartieDTO partie;
}

@ -0,0 +1,23 @@
package fr.iut.sciencequest.sae.dto.invite;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class InviteSimpleDTO extends RepresentationModel<InviteSimpleDTO> {
@NotNull
private Integer id;
@NotBlank
private String pseudo;
}

@ -0,0 +1,20 @@
package fr.iut.sciencequest.sae.dto.invite;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class InviteWithPseudoOnlyDTO extends RepresentationModel<InviteWithPseudoOnlyDTO> {
@NotBlank
private String pseudo;
}

@ -0,0 +1,27 @@
package fr.iut.sciencequest.sae.dto.jeu;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JeuDTO extends RepresentationModel<JeuDTO> {
@NotNull
private Integer id;
@NotBlank
private String nom;
@Min(0)
private Integer nbrParties;
}

@ -0,0 +1,26 @@
package fr.iut.sciencequest.sae.dto.joueur;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JoueurDTO extends RepresentationModel<JoueurDTO> {
@NotNull
private Integer id;
@NotBlank
private String pseudo;
private PartieDTO partieEnCours;
}

@ -0,0 +1,23 @@
package fr.iut.sciencequest.sae.dto.joueur;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JoueurSimpleDTO extends RepresentationModel<JoueurSimpleDTO> {
@NotNull
private Integer id;
@NotBlank
private String pseudo;
}

@ -0,0 +1,36 @@
package fr.iut.sciencequest.sae.dto.partie;
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
import fr.iut.sciencequest.sae.dto.jeu.JeuDTO;
import fr.iut.sciencequest.sae.dto.joueur.JoueurSimpleDTO;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
import fr.iut.sciencequest.sae.entities.Status;
import fr.iut.sciencequest.sae.entities.Thematique;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
import java.util.List;
import java.util.Set;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PartieDTO extends RepresentationModel<PartieDTO> {
@NotNull
private Integer id;
@NotEmpty
private String codeInvitation;
@NotEmpty
private List<JoueurSimpleDTO> joueurs;
@NotEmpty
private List<ThematiqueSimpleDTO> thematiques;
@NotNull
private DifficulteSimpleDTO difficulte;
@NotNull
private Status status;
}

@ -0,0 +1,35 @@
package fr.iut.sciencequest.sae.dto.partieKahoot;
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
import fr.iut.sciencequest.sae.dto.jeu.JeuDTO;
import fr.iut.sciencequest.sae.dto.joueur.JoueurSimpleDTO;
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
import fr.iut.sciencequest.sae.entities.Status;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PartieKahootDTO extends RepresentationModel<PartieKahootDTO> {
@NotNull
private Integer id;
@NotEmpty
private String codeInvitation;
@NotEmpty
private List<JoueurSimpleDTO> joueurs;
@NotEmpty
private List<ThematiqueSimpleDTO> thematiques;
@NotNull
private DifficulteSimpleDTO difficulte;
}

@ -0,0 +1,24 @@
package fr.iut.sciencequest.sae.dto.partieKahoot;
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
import fr.iut.sciencequest.sae.dto.reponse.ReponseSimpleDTO;
import fr.iut.sciencequest.sae.dto.scorePartieJoueur.ScorePartieKahootJoueurDTO;
import fr.iut.sciencequest.sae.entities.Reponse;
import fr.iut.sciencequest.sae.entities.Status;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
import java.util.Calendar;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PartieKahootQuestionDTO extends RepresentationModel<PartieKahootQuestionDTO> {
private QuestionDTO questionActuel;
private Calendar tempsLimiteReponse;
}

@ -0,0 +1,25 @@
package fr.iut.sciencequest.sae.dto.partieKahoot;
import fr.iut.sciencequest.sae.dto.scorePartieJoueur.ScorePartieKahootJoueurDTO;
import fr.iut.sciencequest.sae.entities.Status;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
import java.util.Calendar;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PartieKahootStatusDTO extends RepresentationModel<PartieKahootStatusDTO> {
@NotNull
private Status status;
private List<ScorePartieKahootJoueurDTO> scores;
private Calendar tempsAffichageScore;
}

@ -0,0 +1,28 @@
package fr.iut.sciencequest.sae.dto.question;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.reponse.ReponseSimpleDTO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class QuestionDTO extends RepresentationModel<QuestionDTO> {
@NotNull
private Integer id;
@NotBlank
private String question;
@NotEmpty
private List<ReponseSimpleDTO> reponses;
}

@ -0,0 +1,28 @@
package fr.iut.sciencequest.sae.dto.reponse;
import com.fasterxml.jackson.annotation.JsonInclude;
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ReponseDTO extends RepresentationModel<ReponseDTO> {
@NotNull
private Integer id;
@NotNull
@NotBlank
private String reponse;
@NotEmpty
private QuestionDTO question;
}

@ -0,0 +1,22 @@
package fr.iut.sciencequest.sae.dto.reponse;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ReponseSimpleDTO extends RepresentationModel<ReponseSimpleDTO> {
@NotNull
private Integer id;
@NotNull
@NotBlank
private String reponse;
}

@ -0,0 +1,19 @@
package fr.iut.sciencequest.sae.dto.reponse;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ReponseValideDTO extends RepresentationModel<ReponseValideDTO> {
@NotNull
@NotBlank
private boolean estValide;
}

@ -0,0 +1,53 @@
package fr.iut.sciencequest.sae.dto.scientifique;
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
import fr.iut.sciencequest.sae.entities.Sexe;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.validator.constraints.URL;
import org.springframework.hateoas.RepresentationModel;
import java.math.BigDecimal;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ScientifiqueDTO extends RepresentationModel<ScientifiqueDTO> {
@NotNull
private Integer id;
@NotNull
private DifficulteSimpleDTO difficulte;
@NotNull
private ThematiqueSimpleDTO thematique;
@URL
private String pathToPhoto;
@NotBlank
private String nom;
@NotBlank
private String prenom;
@NotBlank
private String descriptif;
@NotEmpty
private Date dateNaissance;
@NotBlank
private Sexe sexe;
@Size(max=1)
private BigDecimal ratioTrouve;
}

@ -0,0 +1,18 @@
package fr.iut.sciencequest.sae.dto.scientifique;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
import org.springframework.lang.NonNull;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ScientifiqueIdOnlyDTO extends RepresentationModel<ScientifiqueIdOnlyDTO> {
@NotNull
private Integer id;
}

@ -0,0 +1,53 @@
package fr.iut.sciencequest.sae.dto.scientifique;
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
import fr.iut.sciencequest.sae.entities.Sexe;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.validator.constraints.URL;
import org.springframework.hateoas.RepresentationModel;
import java.math.BigDecimal;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ScientifiqueSimpleDTO extends RepresentationModel<ScientifiqueSimpleDTO> {
@NotNull
private Integer id;
@NotNull
private DifficulteSimpleDTO difficulte;
@NotNull
private ThematiqueSimpleDTO thematique;
@URL
private String pathToPhoto;
@NotBlank
private String nom;
@NotBlank
private String prenom;
@NotBlank
private String descriptif;
@NotEmpty
private Date dateNaissance;
@NotBlank
private Sexe sexe;
@Size(max=1)
private BigDecimal ratioTrouve;
}

@ -0,0 +1,18 @@
package fr.iut.sciencequest.sae.dto.scorePartieJoueur;
import fr.iut.sciencequest.sae.dto.joueur.JoueurSimpleDTO;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ScorePartieKahootJoueurDTO extends RepresentationModel<ScorePartieKahootJoueurDTO> {
@NotNull
private JoueurSimpleDTO joueur;
private Integer score;
}

@ -0,0 +1,24 @@
package fr.iut.sciencequest.sae.dto.thematique;
import fr.iut.sciencequest.sae.entities.Scientifique;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ThematiqueDTO extends RepresentationModel<ThematiqueDTO> {
@NotNull
private Integer id;
@NotBlank
private String libelle;
private Iterable<Scientifique> scientifiques;
}

@ -0,0 +1,19 @@
package fr.iut.sciencequest.sae.dto.thematique;
import fr.iut.sciencequest.sae.entities.Scientifique;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ThematiqueIdOnlyDTO extends RepresentationModel<ThematiqueIdOnlyDTO> {
@NotNull
private Integer id;
}

@ -0,0 +1,17 @@
package fr.iut.sciencequest.sae.dto.thematique;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ThematiqueLibelleOnlyDTO extends RepresentationModel<ThematiqueLibelleOnlyDTO> {
@NotBlank
private String libelle;
}

@ -0,0 +1,21 @@
package fr.iut.sciencequest.sae.dto.thematique;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ThematiqueSimpleDTO extends RepresentationModel<ThematiqueSimpleDTO> {
@NotNull
private Integer id;
@NotBlank
private String libelle;
}

@ -0,0 +1,28 @@
package fr.iut.sciencequest.sae.dto.utilisateur;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UtilisateurDTO extends RepresentationModel<UtilisateurDTO> {
@NotNull
private Integer id;
@Email
@NotNull
private String email;
@NotBlank
private String pseudo;
}

@ -0,0 +1,31 @@
package fr.iut.sciencequest.sae.dto.utilisateur;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.springframework.hateoas.RepresentationModel;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UtilisateurWithPasswordDTO extends RepresentationModel<UtilisateurWithPasswordDTO> {
@NotNull
private Integer id;
@Email
@NotNull
private String email;
@NotBlank
private String motDePasse;
@NotBlank
private String pseudo;
}

@ -0,0 +1,27 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name="admin")
public class Admin {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(unique = true)
private String email;
@Column
private String password;
}

@ -0,0 +1,37 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name="difficulte")
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
public class Difficulte {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(unique = true)
private String libelle;
@JsonManagedReference
@OneToMany(mappedBy = "difficulte")
@Fetch(FetchMode.JOIN)
private List<Scientifique> scientifiques;
}

@ -0,0 +1,26 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name="indice")
public class Indice {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String libelle;
@ManyToOne
@JoinColumn(name="idscientifique", nullable = false)
private Scientifique scientifique;
}

@ -0,0 +1,16 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@Data
@Entity
@Table(name = "invite")
@PrimaryKeyJoinColumn(name = "idjoueur")
public class Invite extends Joueur {
}

@ -0,0 +1,27 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.*;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name="jeu")
public class Jeu {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(unique = true)
private String nom;
@Column(name = "nbrparties")
private Integer nbrParties = 0;
}

@ -0,0 +1,38 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Inheritance(strategy = InheritanceType.JOINED)
@Entity
@Table(name="joueur")
public class Joueur {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(unique = true)
private String pseudo;
@JsonBackReference
@ManyToOne
@JoinColumn(name = "idpartieencours")
@Fetch(FetchMode.JOIN)
@EqualsAndHashCode.Exclude
private Partie partieEnCours;
@OneToMany(mappedBy = "joueur")
private List<ScorePartieKahootJoueur> scores;
}

@ -0,0 +1,49 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Inheritance(strategy = InheritanceType.JOINED)
@Entity
@Table(name="partie")
public class Partie {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "codeinvitation", unique = true, nullable = false) //default value : see Schema.sql
private String codeInvitation;
@JsonManagedReference
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
@JoinColumn(name = "idpartieencours")
private List<Joueur> joueurs;
@Column(name = "datecreation") //default value : see Schema.sql
private Date dateCreation;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "thematiqueselectionnee",
joinColumns = @JoinColumn(name = "idpartie"),
inverseJoinColumns = @JoinColumn(name="idthematique")
)
private List<Thematique> thematiques;
@ManyToOne
@JoinColumn(name="iddifficulte", nullable = false)
private Difficulte difficulte;
@Column(name = "status", nullable = false)
@Enumerated(EnumType.STRING)
private Status status = Status.Pending;
}

@ -0,0 +1,45 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.Calendar;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name="partiekahoot")
@PrimaryKeyJoinColumn(name = "idpartie")
public class PartieKahoot extends Partie {
@ManyToOne
@JoinColumn(name="idquestionactuel")
private Question questionActuel;
@Column(name = "tempslimitereponse")
@Temporal(TemporalType.TIMESTAMP)
private Calendar tempsLimiteReponse;
@Column(name = "tempsaffichagescore")
@Temporal(TemporalType.TIMESTAMP)
private Calendar tempsAffichageScore;
@JsonManagedReference
@OneToMany(mappedBy = "partie", fetch = FetchType.EAGER)
private List<QuestionPartieKahoot> questions;
@JsonManagedReference
@OneToMany(mappedBy = "partie", fetch = FetchType.EAGER)
private List<ReponsePartieKahoot> reponses;
@JsonManagedReference
@OneToMany(mappedBy = "partie", fetch = FetchType.EAGER)
private List<ScorePartieKahootJoueur> scores;
}

@ -0,0 +1,32 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name="question")
public class Question {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String question;
@JsonManagedReference
@OneToMany(mappedBy = "question")
@Fetch(FetchMode.JOIN) // Sinon crash (Could not write JSON: failed to lazily initialize a collection of T)
private List<Reponse> reponses;
}

@ -0,0 +1,34 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name="questionpartiekahoot")
public class QuestionPartieKahoot {
@EmbeddedId
private QuestionPartieKahootKey id = new QuestionPartieKahootKey();
@JsonBackReference
@ManyToOne
@MapsId("idQuestion")
@JoinColumn(name = "idquestion")
private Question question;
@JsonBackReference
@ManyToOne
@MapsId("idPartieKahoot")
@JoinColumn(name="idpartiekahoot")
private PartieKahoot partie;
@Column(name = "aetepose")
private boolean aEtePose = false;
}

@ -0,0 +1,22 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Embeddable
public class QuestionPartieKahootKey implements Serializable {
@Column(name="idquestion")
private Integer idQuestion;
@Column(name="idpartiekahoot")
private Integer idPartieKahoot;
}

@ -0,0 +1,33 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name="reponse")
public class Reponse{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String reponse;
@Column(name = "estvalide")
private Boolean estValide;
@JsonBackReference
@ManyToOne
@JoinColumn(name = "idquestion", nullable = false)
private Question question;
@JsonBackReference
@ManyToOne
@JoinColumn(name = "idscientifique", nullable = false)
private Scientifique scientifique;
}

@ -0,0 +1,40 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name="reponsepartiekahootjoueur")
public class ReponsePartieKahoot {
@EmbeddedId
private ReponsePartieKahootKey id = new ReponsePartieKahootKey();
@JsonBackReference
@ManyToOne
@MapsId("idQuestion")
@JoinColumn(name = "idquestion")
private Question question;
@JsonBackReference
@ManyToOne
@MapsId("idPartie")
@JoinColumn(name="idpartie")
private PartieKahoot partie;
@JsonBackReference
@ManyToOne
@MapsId("idJoueur")
@JoinColumn(name="idjoueur")
private Joueur joueur;
@JsonBackReference
@ManyToOne
@JoinColumn(name = "idreponse")
private Reponse reponse;
}

@ -0,0 +1,25 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Embeddable
public class ReponsePartieKahootKey implements Serializable {
@Column(name="idquestion")
private Integer idQuestion;
@Column(name="idpartie")
private Integer idPartie;
@Column(name="idjoueur")
private Integer idJoueur;
}

@ -0,0 +1,60 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
@AllArgsConstructor
@RequiredArgsConstructor
//@Relation(collectionRelation = "scientifiques", itemRelation = "scientifique")
@Data
@Entity
@Table(name = "scientifique")
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
public class Scientifique {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@JsonBackReference
@ManyToOne
@JoinColumn(name="iddifficulte", nullable = false)
private Difficulte difficulte;
@JsonBackReference
@ManyToOne
@JoinColumn(name="idthematique", nullable = false)
private Thematique thematique;
@Column(name = "photo")
private String pathToPhoto;
@Column(nullable = false)
private String nom;
@Column(nullable = false)
private String prenom;
@Column(nullable = false)
private String descriptif;
@Column(name = "datenaissance", nullable = false)
private Date dateNaissance;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private Sexe sexe;
@Column(name = "ratiotrouvee")
private BigDecimal ratioTrouve = BigDecimal.ZERO;
}

@ -0,0 +1,31 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name="scorepartiekahootjoueur")
public class ScorePartieKahootJoueur {
@EmbeddedId
private ScorePartieKahootJoueurKey id = new ScorePartieKahootJoueurKey();
@ManyToOne
@MapsId("idJoueur")
@JoinColumn(name = "idjoueur")
private Joueur joueur;
@ManyToOne
@MapsId("idPartie")
@JoinColumn(name="idpartie")
private Partie partie;
private Integer score = 0;
}

@ -0,0 +1,22 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Embeddable
public class ScorePartieKahootJoueurKey implements Serializable {
@Column(name="idjoueur")
private Integer idJoueur;
@Column(name="idpartie")
private Integer idPartie;
}

@ -0,0 +1,6 @@
package fr.iut.sciencequest.sae.entities;
public enum Sexe {
F,
H
}

@ -0,0 +1,8 @@
package fr.iut.sciencequest.sae.entities;
public enum Status {
Pending,
Started,
DisplayingScore,
Ended
}

@ -0,0 +1,41 @@
package fr.iut.sciencequest.sae.entities;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name="thematique")
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
public class Thematique {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(unique = true)
private String libelle;
@JsonManagedReference
@OneToMany(mappedBy = "thematique")
@Fetch(FetchMode.JOIN)
private List<Scientifique> scientifiques;
@ManyToMany(mappedBy = "thematiques")
List<Partie> parties;
}

@ -0,0 +1,24 @@
package fr.iut.sciencequest.sae.entities;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name="utilisateur")
@PrimaryKeyJoinColumn(name = "idjoueur")
public class Utilisateur extends Joueur {
@Column(unique = true)
private String email;
@Column(name = "password")
private String motDePasse;
}

@ -0,0 +1,22 @@
package fr.iut.sciencequest.sae.exceptions;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import java.util.List;
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
@ResponseStatus(HttpStatus.CONFLICT)
public class DuplicatedFieldException extends RuntimeException {
//TODO : retourner une erreur avec le msg + LA LISTE des fields concernés en format JSON
public DuplicatedFieldException(String field){
super("Unicity constraints broken on fields :" + listOf(field));
}
public DuplicatedFieldException(List<String> fields){
super("Unicity constraints broken on fields :" + fields);
}
}

@ -0,0 +1,11 @@
package fr.iut.sciencequest.sae.exceptions;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.CONFLICT)
public class DuplicatedIdException extends RuntimeException{
public DuplicatedIdException(){
super("duplicated id");
}
}

@ -0,0 +1,12 @@
package fr.iut.sciencequest.sae.exceptions;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_ACCEPTABLE)
public class IncorrectPageException extends RuntimeException {
public IncorrectPageException(String exception) {
super(exception);
}
}

@ -0,0 +1,11 @@
package fr.iut.sciencequest.sae.exceptions;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.FORBIDDEN)
public class IncorrectPasswordException extends RuntimeException {
public IncorrectPasswordException() {
super("Incorrect password");
}
}

@ -0,0 +1,33 @@
package fr.iut.sciencequest.sae.exceptions;
import jakarta.annotation.Nullable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import java.util.HashMap;
import java.util.Map;
@ControllerAdvice
public class ValidationHandler extends ResponseEntityExceptionHandler {
@Override
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, @Nullable HttpHeaders headers, @Nullable HttpStatusCode status, @Nullable WebRequest request) {
Map<String, String> errors = new HashMap<>();
ex.getBindingResult().getAllErrors().forEach((error) ->{
String fieldName = ((FieldError) error).getField();
String message = error.getDefaultMessage();
errors.put(fieldName, message);
});
return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
}
}

@ -0,0 +1,7 @@
package fr.iut.sciencequest.sae.exceptions.notFound;
public class DifficulteNotFoundException extends EntityNotFoundException{
public DifficulteNotFoundException(int id) {
super("Difficulté", id);
}
}

@ -0,0 +1,19 @@
package fr.iut.sciencequest.sae.exceptions.notFound;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND)
public abstract class EntityNotFoundException extends RuntimeException {
public EntityNotFoundException(){
super("entity not found");
}
public EntityNotFoundException(String entityName, Object id){
super(entityName + " not found with id : " + id);
}
public EntityNotFoundException(String entityName, String fieldName, Object value){
super(entityName + " not found with " + fieldName + " : " + value);
}
}

@ -0,0 +1,7 @@
package fr.iut.sciencequest.sae.exceptions.notFound;
public class IndiceNotFoundException extends EntityNotFoundException{
public IndiceNotFoundException(int id){
super("indice", id);
}
}

@ -0,0 +1,11 @@
package fr.iut.sciencequest.sae.exceptions.notFound;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND)
public class InviteNotFoundException extends EntityNotFoundException{
public InviteNotFoundException(int id) {
super("Invite", id);
}
}

@ -0,0 +1,11 @@
package fr.iut.sciencequest.sae.exceptions.notFound;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND)
public class JeuNotFoundException extends EntityNotFoundException{
public JeuNotFoundException(int id) {
super("Jeu", id);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save