Merge remote-tracking branch 'origin/master'
This commit is contained in:
		| @ -1,6 +1,15 @@ | ||||
| ## Building phase | ||||
| FROM gradle:jdk21-alpine AS BUILD | ||||
| WORKDIR /backend | ||||
|    | ||||
| COPY . . | ||||
| RUN gradle build -x test | ||||
|  | ||||
| ## Running Phase | ||||
| FROM eclipse-temurin:21-jdk-alpine | ||||
| VOLUME /tmp | ||||
| WORKDIR /backend | ||||
| VOLUME /cdn | ||||
| ENV SPRING_PROFILES_ACTIVE=prod | ||||
| COPY build/libs/backend-0.0.1-SNAPSHOT.jar /app.jar | ||||
| ENTRYPOINT ["java", "-jar", "/app.jar"] | ||||
| # ENV SPRING_PROFILES_ACTIVE=prod | ||||
| COPY --from=BUILD /backend/build/libs/Clyde-0.0.1-SNAPSHOT.jar /backend/app.jar | ||||
| EXPOSE 8080 | ||||
| ENTRYPOINT ["java", "-jar", "/backend/app.jar"] | ||||
|  | ||||
							
								
								
									
										13
									
								
								backend/settings.gradle.kts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								backend/settings.gradle.kts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | ||||
| /* | ||||
|  * This file was generated by the Gradle 'init' task. | ||||
|  * | ||||
|  * The settings file is used to specify which projects to include in your build. | ||||
|  * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.6/userguide/multi_project_builds.html in the Gradle documentation. | ||||
|  */ | ||||
|  | ||||
| plugins { | ||||
|     // Apply the foojay-resolver plugin to allow automatic download of JDKs | ||||
|     id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" | ||||
| } | ||||
|  | ||||
| rootProject.name = "Clyde" | ||||
| @ -64,8 +64,8 @@ public class ApplicationsController { | ||||
|         if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Secretary,Role.Admin},token)) | ||||
|             authorizedApps.add(Applications.ManageCourses); | ||||
|  | ||||
|         if (!authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token)){ | ||||
|             authorizedApps.add(Applications.Inscription); | ||||
|         if (!authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin, Role.Teacher},token)){ | ||||
|             authorizedApps.add(Applications.Requests); | ||||
|             authorizedApps.add(Applications.StudentsList);} | ||||
|  | ||||
|         if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){  | ||||
|  | ||||
| @ -135,4 +135,5 @@ public class CourseController { | ||||
|         courseServ.delete(courseServ.findById(id)); | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -4,11 +4,13 @@ package ovh.herisson.Clyde.EndPoints; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository; | ||||
| import ovh.herisson.Clyde.Responses.UnauthorizedResponse; | ||||
| import ovh.herisson.Clyde.Services.*; | ||||
| import ovh.herisson.Clyde.Tables.Curriculum; | ||||
| import ovh.herisson.Clyde.Tables.Role; | ||||
| import ovh.herisson.Clyde.Tables.*; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | ||||
| @RestController | ||||
| @ -21,12 +23,18 @@ public class CurriculumController { | ||||
|  | ||||
|     private final UserCurriculumService userCurriculumServ; | ||||
|     private final CurriculumCourseService curriculumCourseServ; | ||||
|     private final InscriptionRepository ir; | ||||
|     private final UserService userServ; | ||||
|  | ||||
|     public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ){ | ||||
|     private final ExternalCurriculumRepository ecr; | ||||
|     public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, InscriptionRepository ir, UserService userServ, ExternalCurriculumRepository ecr){ | ||||
|         this.curriculumServ = curriculumServ; | ||||
|         this.authServ = authServ; | ||||
|         this.userCurriculumServ = userCurriculumServ; | ||||
|         this.curriculumCourseServ = curriculumCourseServ; | ||||
|         this.ir = ir; | ||||
|         this.userServ = userServ; | ||||
|         this.ecr = ecr; | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/curriculum/{id}") | ||||
| @ -52,6 +60,22 @@ public class CurriculumController { | ||||
|         return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(curriculum),HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     //Return the list of all curicullums of an user | ||||
|     @GetMapping("/onescurriculum/{userId}") | ||||
|     public ResponseEntity<Map<String ,Object>> findOnesCurriculum(@RequestHeader("Authorization") String token, @PathVariable String userId){ | ||||
|         if (authServ.getUserFromToken(token) == null) | ||||
|             return new UnauthorizedResponse<>(null); | ||||
|  | ||||
|         User u = userServ.getUserById(Long.parseLong(userId)); | ||||
|         HashMap<String,Object> toReturn = userCurriculumServ.findAllCurriculumByStudent(u); | ||||
|  | ||||
|         if (toReturn == null) | ||||
|             return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||||
|  | ||||
|         return new ResponseEntity<>(toReturn,HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/curriculums") | ||||
|     public ResponseEntity<Iterable<Map<String, Object>>> findAllIndDepth(){ | ||||
|         return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),HttpStatus.OK); | ||||
| @ -94,4 +118,5 @@ public class CurriculumController { | ||||
|         curriculumServ.delete(toDelete); | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,55 @@ | ||||
| package ovh.herisson.Clyde.EndPoints.Inscription; | ||||
|  | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository; | ||||
| import ovh.herisson.Clyde.Repositories.UserRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Map; | ||||
|  | ||||
| @RestController | ||||
| @CrossOrigin(originPatterns = "*", allowCredentials = "true") | ||||
| public class ExternalCurriculumController { | ||||
|  | ||||
|     public final ExternalCurriculumRepository ecr; | ||||
|     public final InscriptionRepository inscriptionRepository; | ||||
|     public final UserRepository userRepository; | ||||
|  | ||||
|     public ExternalCurriculumController(ExternalCurriculumRepository ecr, InscriptionRepository inscriptionRepository, UserRepository userRepository) { | ||||
|         this.ecr = ecr; | ||||
|         this.inscriptionRepository = inscriptionRepository; | ||||
|         this.userRepository = userRepository; | ||||
|     } | ||||
|  | ||||
|     //everyone can post some externalcurriculums (the validity of the elements is assured by the inscription service) | ||||
|     @PostMapping("/externalcurriculum") | ||||
|     public ResponseEntity<ExternalCurriculum> postExternalCurriculum(@RequestBody Map<String, Object> externalCurrInfos){ | ||||
|         InscriptionRequest ir = inscriptionRepository.findById((Integer) externalCurrInfos.get("inscriptionRequestId")); | ||||
|  | ||||
|         ExternalCurriculum toSave = new ExternalCurriculum(ir, (String) externalCurrInfos.get("school"),(String) externalCurrInfos.get("formation"),(String) externalCurrInfos.get("completion"), (Integer)externalCurrInfos.get("startYear"), (Integer)externalCurrInfos.get("endYear"), (String)externalCurrInfos.get("justifDocUrl"), null); | ||||
|  | ||||
|         return new ResponseEntity<>(ecr.save(toSave), HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/externalcurriculum/{inscReqId}") | ||||
|     public ResponseEntity<ArrayList<ExternalCurriculum>> getExternalCurrListByInscrReq(@PathVariable long inscReqId){ | ||||
|         InscriptionRequest ir = inscriptionRepository.findById(inscReqId); | ||||
|  | ||||
|         ArrayList<ExternalCurriculum> toReturn = ecr.getExternalCurriculumByInscriptionRequest(ir); | ||||
|         return new ResponseEntity<>(toReturn, HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/externalcurriculumbyuser/{userId}") | ||||
|     public ResponseEntity<ArrayList<ExternalCurriculum>> getExternalCurrByUser(@PathVariable long userId){ | ||||
|         User user = userRepository.findById(userId); | ||||
|  | ||||
|         ArrayList<ExternalCurriculum> toReturn = ecr.getExternalCurriculumByUser(user); | ||||
|         return new ResponseEntity<>(toReturn, HttpStatus.OK); | ||||
|     } | ||||
| } | ||||
| @ -1,13 +1,13 @@ | ||||
| package ovh.herisson.Clyde.EndPoints; | ||||
| package ovh.herisson.Clyde.EndPoints.Inscription; | ||||
| 
 | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Responses.UnauthorizedResponse; | ||||
| import ovh.herisson.Clyde.Services.AuthenticatorService; | ||||
| import ovh.herisson.Clyde.Services.InscriptionService; | ||||
| import ovh.herisson.Clyde.Services.Inscription.InscriptionService; | ||||
| import ovh.herisson.Clyde.Services.ProtectionService; | ||||
| import ovh.herisson.Clyde.Tables.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| import ovh.herisson.Clyde.Tables.Role; | ||||
| import java.util.Map; | ||||
| @ -79,4 +79,22 @@ public class InscriptionController { | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     //Allow teacher or admin to accept or refuse the equivalence | ||||
|     @PatchMapping("/request/registerequiv/{id}/{newstate}") | ||||
|     public ResponseEntity<Object> editRegisterEquiv(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newstate){ | ||||
|         if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher}, token)) | ||||
|             return new UnauthorizedResponse<>(null); | ||||
| 
 | ||||
|         InscriptionRequest toEdit = inscriptionServ.getById(id); | ||||
|         toEdit.setEquivalenceState(newstate); | ||||
| 
 | ||||
|         inscriptionServ.save(toEdit); | ||||
| 
 | ||||
|         if (toEdit.getState() == RequestState.Accepted && (toEdit.getEquivalenceState() == RequestState.Accepted || toEdit.getEquivalenceState() == RequestState.Unrequired)) | ||||
|         { | ||||
|             inscriptionServ.createUser(toEdit); | ||||
|         } | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,55 @@ | ||||
| package ovh.herisson.Clyde.EndPoints.Inscription; | ||||
|  | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository; | ||||
| import ovh.herisson.Clyde.Responses.UnauthorizedResponse; | ||||
| import ovh.herisson.Clyde.Services.AuthenticatorService; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.Minerval; | ||||
| import ovh.herisson.Clyde.Tables.Role; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| @RestController | ||||
| @CrossOrigin(originPatterns = "*", allowCredentials = "true") | ||||
| public class MinervalController { | ||||
|     private final AuthenticatorService authServ; | ||||
|     private final MinervalRepository mr; | ||||
|  | ||||
|     public MinervalController(AuthenticatorService authServ, MinervalRepository mr) { | ||||
|         this.authServ = authServ; | ||||
|         this.mr = mr; | ||||
|     } | ||||
|  | ||||
|     //A new minerval entry is posted when the inscription service accept a registration request | ||||
|     @PostMapping("/minerval/{studentRegNo}") | ||||
|     public ResponseEntity<Object> postMinerval(@RequestHeader("Authorization") String token, @PathVariable long studentRegNo){ | ||||
|         if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) | ||||
|             return new UnauthorizedResponse<>(null); | ||||
|  | ||||
|         Calendar c = new GregorianCalendar(); | ||||
|  | ||||
|         mr.save(new Minerval(studentRegNo, 0, 835, c.get(Calendar.YEAR))); | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/minerval/{studentRegNo}") | ||||
|     public ResponseEntity<Minerval> getCurrentMinervalbyRegNo(@PathVariable long studentRegNo){ | ||||
|         ArrayList<Minerval> mlist = mr.getMinervalsByStudentRegNoOrderByYearDesc(studentRegNo); | ||||
|  | ||||
|         //The list is ordered by year in descending order then the index 0 contains the actual minerval (for this year) | ||||
|         Minerval m = mlist.get(0); | ||||
|         return new ResponseEntity<>(m, HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     @PatchMapping("/minerval") | ||||
|     public ResponseEntity<Object> updateMinerval(@RequestBody Minerval updatedMinerval){ | ||||
|         Minerval minerval = mr.findById(updatedMinerval.getId()); | ||||
|  | ||||
|         minerval.setPaidAmount(updatedMinerval.getPaidAmount()); | ||||
|         minerval.setToPay(updatedMinerval.getToPay()); | ||||
|         mr.save(minerval); | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,37 @@ | ||||
| package ovh.herisson.Clyde.EndPoints.Inscription; | ||||
|  | ||||
|  | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.PaymentRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.Payment; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| @RestController | ||||
| @CrossOrigin(originPatterns = "*", allowCredentials = "true") | ||||
| public class PaymentController { | ||||
|  | ||||
|     private final PaymentRepository paymentRepository; | ||||
|  | ||||
|     public PaymentController(PaymentRepository paymentRepository){ | ||||
|         this.paymentRepository = paymentRepository; | ||||
|     } | ||||
|  | ||||
|     //Post a payment record | ||||
|     @PostMapping("/payment") | ||||
|     public ResponseEntity<Object> postPayment(@RequestBody Payment payment){ | ||||
|         paymentRepository.save(payment); | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     //Get all payment records of a student | ||||
|     @GetMapping("/payment/{studentRegNo}") | ||||
|     public ResponseEntity<ArrayList<Payment>> getPaymentsByUser(@PathVariable long studentRegNo){ | ||||
|         ArrayList<Payment> toReturn = paymentRepository.getPaymentsByStudentRegNo(studentRegNo); | ||||
|         return new ResponseEntity<>(toReturn, HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,97 @@ | ||||
| package ovh.herisson.Clyde.EndPoints.Inscription; | ||||
|  | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.CourseRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ExemptionsRequestRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.UninscriptionRequestRepository; | ||||
| import ovh.herisson.Clyde.Repositories.UserRepository; | ||||
| import ovh.herisson.Clyde.Responses.UnauthorizedResponse; | ||||
| import ovh.herisson.Clyde.Services.AuthenticatorService; | ||||
| import ovh.herisson.Clyde.Tables.*; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.Map; | ||||
|  | ||||
| @RestController | ||||
| @CrossOrigin(originPatterns = "*", allowCredentials = "true") | ||||
| public class RequestsController { | ||||
|  | ||||
|     public final ExemptionsRequestRepository err; | ||||
|     public final ScholarshipRequestRepository srr; | ||||
|     public final UserRepository userRepository; | ||||
|     public final AuthenticatorService authServ; | ||||
|     public final UninscriptionRequestRepository uninscriptionRequestRepository; | ||||
|     public final CourseRepository courseRepository; | ||||
|  | ||||
|     public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UninscriptionRequestRepository uninscriptionRequestRepository, CourseRepository courseRepository) { | ||||
|         this.err = err; | ||||
|         this.srr = srr; | ||||
|         this.userRepository = userRepository; | ||||
|         this.authServ = authServ; | ||||
|         this.uninscriptionRequestRepository = uninscriptionRequestRepository; | ||||
|         this.courseRepository = courseRepository; | ||||
|     } | ||||
|  | ||||
|     @PostMapping(value="/exemptionreq") | ||||
|     public ResponseEntity<String> createExemptionReq(@RequestBody Map<String, Object> exemptionsRequestInfo){ | ||||
|         User user = userRepository.findById((Integer) exemptionsRequestInfo.get("userRegNo")); | ||||
|         Course course = courseRepository.findById((Integer) exemptionsRequestInfo.get("courseId")); | ||||
|  | ||||
|         ExemptionsRequest exemptionsRequest = new ExemptionsRequest(user, course, (String) exemptionsRequestInfo.get("justifDocument"), RequestState.Pending, new Date()); | ||||
|  | ||||
|         err.save(exemptionsRequest); | ||||
|  | ||||
|         return new ResponseEntity<>(HttpStatus.CREATED); | ||||
|     } | ||||
|  | ||||
|     @PostMapping(value="/scholarshipreq") | ||||
|     public ResponseEntity<String> createScholarshipReq(@RequestBody Map<String, Object> scholarshipRequestInfo){ | ||||
|         User user = userRepository.findById((Integer)scholarshipRequestInfo.get("userId")); | ||||
|         ScholarshipRequest toCreate = new ScholarshipRequest(user, RequestState.Pending, 0, new Date(), (String) scholarshipRequestInfo.get("taxDocUrl"), (String) scholarshipRequestInfo.get("residencyDocUrl")); | ||||
|  | ||||
|         srr.save(toCreate); | ||||
|  | ||||
|         return new ResponseEntity<>(HttpStatus.CREATED); | ||||
|     } | ||||
|  | ||||
|     //Get all the exemptions Request | ||||
|     @GetMapping(value = "/exemptionsreq") | ||||
|     public ResponseEntity<ArrayList<ExemptionsRequest>> getAllExemptionsRequests(@RequestHeader("Authorization") String token){ | ||||
|         if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) | ||||
|             return new UnauthorizedResponse<>(null); | ||||
|  | ||||
|         ArrayList<ExemptionsRequest> toReturn = new ArrayList<>(); | ||||
|  | ||||
|         err.findAll().forEach(toReturn::add); | ||||
|  | ||||
|         return new ResponseEntity<>(toReturn, HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     //Get all the scholarships requests | ||||
|     @GetMapping(value = "/scholarshipreq") | ||||
|     public ResponseEntity<ArrayList<ScholarshipRequest>> getAllScholarshipRequests(@RequestHeader("Authorization") String token){ | ||||
|         if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) | ||||
|             return new UnauthorizedResponse<>(null); | ||||
|  | ||||
|         ArrayList<ScholarshipRequest> toReturn = new ArrayList<>(); | ||||
|  | ||||
|         srr.findAll().forEach(toReturn::add); | ||||
|  | ||||
|         return new ResponseEntity<>(toReturn, HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     @PostMapping(value = "/uninscriptionreq") | ||||
|     public ResponseEntity<String> postUnregReq(@RequestBody Map<String,Object> uninscr){ | ||||
|         User u = userRepository.findById((int) uninscr.get("userId")); | ||||
|         UninscriptionRequest ur = new UninscriptionRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u); | ||||
|         uninscriptionRequestRepository.save(ur); | ||||
|         return new ResponseEntity<>(HttpStatus.OK); | ||||
|     } | ||||
| } | ||||
| @ -5,10 +5,14 @@ import org.springframework.http.HttpHeaders; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.CurriculumRepository; | ||||
| import ovh.herisson.Clyde.Responses.UnauthorizedResponse; | ||||
| import ovh.herisson.Clyde.Services.AuthenticatorService; | ||||
| import ovh.herisson.Clyde.Services.ProtectionService; | ||||
| import ovh.herisson.Clyde.Tables.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.Curriculum; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
|  | ||||
| import java.util.Date; | ||||
| import java.util.Map; | ||||
|  | ||||
| @ -16,7 +20,7 @@ import java.util.Map; | ||||
| @CrossOrigin(originPatterns = "*", allowCredentials = "true") | ||||
| public class LoginController { | ||||
|     private final AuthenticatorService authServ; | ||||
|  | ||||
|     private final CurriculumRepository curriculumRepository; | ||||
|     static public class RequestLogin{ | ||||
|         private final String identifier; | ||||
|         private final String password; | ||||
| @ -29,8 +33,9 @@ public class LoginController { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public LoginController(AuthenticatorService authServ){ | ||||
|     public LoginController(AuthenticatorService authServ, CurriculumRepository curriculumRepository){ | ||||
|         this.authServ = authServ; | ||||
|         this.curriculumRepository = curriculumRepository; | ||||
|     } | ||||
|  | ||||
|     @PostMapping(value = "/login") | ||||
| @ -48,9 +53,18 @@ public class LoginController { | ||||
|  | ||||
|     @PostMapping("/register") | ||||
|     public ResponseEntity<Map<String,Object>> register(@RequestBody InscriptionRequest inscriptionRequest){ | ||||
|         //We ensure here that if the targeted cursus year is more than first grade then we need the teacher equivalence approval | ||||
|         Curriculum curr = curriculumRepository.findById(inscriptionRequest.getCurriculumId()); | ||||
|  | ||||
|         if (curr.getYear() > 1){ | ||||
|             inscriptionRequest.setEquivalenceState(RequestState.Pending); | ||||
|         }else{ | ||||
|             inscriptionRequest.setEquivalenceState(RequestState.Unrequired); | ||||
|         } | ||||
|  | ||||
|         InscriptionRequest returnedInscriptionRequest = authServ.register(inscriptionRequest); | ||||
|  | ||||
|  | ||||
|         return new ResponseEntity<>(ProtectionService.requestWithoutPassword(returnedInscriptionRequest), HttpStatus.CREATED); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -2,8 +2,10 @@ package ovh.herisson.Clyde.EndPoints; | ||||
|  | ||||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.TokenRepository; | ||||
| import ovh.herisson.Clyde.Repositories.UserRepository; | ||||
| import ovh.herisson.Clyde.Repositories.*; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository; | ||||
| import ovh.herisson.Clyde.Services.*; | ||||
| import ovh.herisson.Clyde.Services.ScientificPublications.ResearchesService; | ||||
| import ovh.herisson.Clyde.Tables.*; | ||||
| @ -11,6 +13,11 @@ import ovh.herisson.Clyde.Tables.ScientificPublications.Access; | ||||
| import ovh.herisson.Clyde.Tables.ScientificPublications.PaperType; | ||||
| import ovh.herisson.Clyde.Tables.ScientificPublications.Research; | ||||
| import ovh.herisson.Clyde.Tables.ScientificPublications.Researcher; | ||||
| import ovh.herisson.Clyde.Services.Inscription.InscriptionService; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.Minerval; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| @ -18,7 +25,6 @@ import java.util.Date; | ||||
|  | ||||
| @RestController | ||||
| @CrossOrigin(originPatterns = "*", allowCredentials = "true") | ||||
|  | ||||
| public class MockController { | ||||
|     private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | ||||
|  | ||||
| @ -28,22 +34,28 @@ public class MockController { | ||||
|     public final CurriculumCourseService CurriculumCourseService; | ||||
|     public final CurriculumService curriculumService; | ||||
|     public final CourseService courseService; | ||||
|  | ||||
|     public final ExternalCurriculumRepository externalCurriculumRepository; | ||||
|     public final InscriptionService inscriptionService; | ||||
|  | ||||
|     public final ResearchesService researchesService; | ||||
|     public final UserCurriculumRepository ucr; | ||||
|     public final MinervalRepository minervalRepository; | ||||
|     public final ScholarshipRequestRepository scholarshipRequestRepository; | ||||
|  | ||||
|     ArrayList<User> mockUsers; | ||||
|  | ||||
|  | ||||
|     public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService, ResearchesService researchesService){ | ||||
|     public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository,  ResearchesService researchesService, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository){ | ||||
|         this.tokenRepo = tokenRepo; | ||||
|         this.userRepo = userRepo; | ||||
|         this.tokenService = tokenService; | ||||
|         this.CurriculumCourseService = CurriculumCourseService; | ||||
|         this.curriculumService = curriculumService; | ||||
|         this.courseService = courseService; | ||||
|         this.externalCurriculumRepository = externalCurriculumRepository; | ||||
|         this.inscriptionService = inscriptionService; | ||||
|         this.researchesService = researchesService; | ||||
|         this.ucr = ucr; | ||||
|         this.minervalRepository = minervalRepository; | ||||
|         this.scholarshipRequestRepository = scholarshipRequestRepository; | ||||
|     } | ||||
|  | ||||
|     /** Saves an example of each user type by : | ||||
| @ -53,82 +65,99 @@ public class MockController { | ||||
|      */ | ||||
|  | ||||
|     @PostMapping("/mock") | ||||
|     public void postMock(){ | ||||
|     public void postMock() { | ||||
|  | ||||
|         // user part | ||||
|             // user part | ||||
|             User herobrine = new User("brine", "hero", "admin@admin.com", "behind", "ShadowsLand", new Date(0), null, Role.Admin, passwordEncoder.encode("admin")); | ||||
|             User joe = new User("Mama", "Joe", "student@student.com", "roundabout", "England", new Date(0), null, Role.Student, passwordEncoder.encode("student")); | ||||
|             User meh = new User("Polo", "Marco", "secretary@secretary.com", "a Box", "Monaco", new Date(0), null, Role.Secretary, passwordEncoder.encode("secretary")); | ||||
|             User joke = new User("Gaillard", "Corentin", "teacher@teacher.com", "lab", "faculty", new Date(0), null, Role.Teacher, passwordEncoder.encode("teacher")); | ||||
|             User jojo = new User("Bridoux", "Justin", "teacher2@teacher2.com", "lab", "faculty", new Date(0), null, Role.Teacher, passwordEncoder.encode("teacher")); | ||||
|             User lena = new User("Louille", "Lena", "inscriptionService@InscriptionService.com", "no", "yes", new Date(0), null, Role.InscriptionService, passwordEncoder.encode("inscriptionService")); | ||||
|             User popo = new User("Smith", "Paul", "paulsmith@gmail.com", "306 rue du poulet", "belgique", new Date(0), null, Role.Student, passwordEncoder.encode("jesuispaulleroi")); | ||||
|             mockUsers = new ArrayList<>(Arrays.asList(herobrine, joe, meh, joke, lena, jojo, popo)); | ||||
|  | ||||
|             userRepo.saveAll(mockUsers); | ||||
|  | ||||
|             Minerval minerval = new Minerval(joe.getRegNo(), 0, 852, 2023); | ||||
|             minervalRepository.save(minerval); | ||||
|             // Course / Curriculum part | ||||
|  | ||||
|             Curriculum infoBab1 = new Curriculum(1, "info"); | ||||
|             Curriculum chemistryBab1 = new Curriculum(1, "chemistry"); | ||||
|             Curriculum psychologyBab1 = new Curriculum(1, "psychology"); | ||||
|             Curriculum infoBab2 = new Curriculum(2, "info"); | ||||
|             Curriculum masterinfo1 = new Curriculum(4, "info"); | ||||
|             Curriculum masterinfo2 = new Curriculum(5, "info"); | ||||
|  | ||||
|             curriculumService.save(infoBab1); | ||||
|             curriculumService.save(chemistryBab1); | ||||
|             curriculumService.save(psychologyBab1); | ||||
|             curriculumService.save(infoBab2); | ||||
|             curriculumService.save(masterinfo1); | ||||
|             curriculumService.save(masterinfo2); | ||||
|  | ||||
|             ucr.save(new UserCurriculum(joe, infoBab1, 2022)); | ||||
|             ucr.save(new UserCurriculum(joe, chemistryBab1, 2023)); | ||||
|             ucr.save(new UserCurriculum(joe, infoBab1, 2023)); | ||||
|             ucr.save(new UserCurriculum(joe, psychologyBab1, 2020)); | ||||
|             ucr.save(new UserCurriculum(popo, infoBab1, 2022)); | ||||
|             ucr.save(new UserCurriculum(popo, infoBab2, 2023)); | ||||
|  | ||||
|             Course progra1 = new Course(5, "Programmation et algorithmique 1", joke); | ||||
|             Course chemistry1 = new Course(12, "Thermochimie", joke); | ||||
|             Course psycho1 = new Course(21, "Neuroreaction of isolated brain cells", joke); | ||||
|             Course commun = new Course(2, "cours commun", joke); | ||||
|  | ||||
|             courseService.save(progra1); | ||||
|             courseService.save(chemistry1); | ||||
|             courseService.save(psycho1); | ||||
|             courseService.save(commun); | ||||
|  | ||||
|             ScholarshipRequest ssr1 = new ScholarshipRequest(joe, RequestState.Pending, 0, new Date(), "test", "test"); | ||||
|             scholarshipRequestRepository.save(ssr1); | ||||
|  | ||||
|             CurriculumCourseService.save(new CurriculumCourse(infoBab1, progra1)); | ||||
|             CurriculumCourseService.save(new CurriculumCourse(infoBab1, commun)); | ||||
|             CurriculumCourseService.save(new CurriculumCourse(infoBab1, psycho1)); | ||||
|             CurriculumCourseService.save(new CurriculumCourse(psychologyBab1, psycho1)); | ||||
|             CurriculumCourseService.save(new CurriculumCourse(psychologyBab1, commun)); | ||||
|  | ||||
|  | ||||
|         User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin")); | ||||
|         User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student")); | ||||
|         User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary")); | ||||
|         User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); | ||||
|         User jojo = new User("Bridoux","Justin","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); | ||||
|         User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService")); | ||||
|         mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo)); | ||||
|  | ||||
|         userRepo.saveAll(mockUsers); | ||||
|  | ||||
|         // Course / Curriculum part | ||||
|  | ||||
|         Curriculum infoBab1 = new Curriculum(1,"info"); | ||||
|         Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); | ||||
|         Curriculum psychologyBab1 = new Curriculum(1,"psychology"); | ||||
|  | ||||
|         curriculumService.save(infoBab1); | ||||
|         curriculumService.save(chemistryBab1); | ||||
|         curriculumService.save(psychologyBab1); | ||||
|             CurriculumCourseService.save(new CurriculumCourse(chemistryBab1, commun)); | ||||
|             CurriculumCourseService.save(new CurriculumCourse(chemistryBab1, chemistry1)); | ||||
|  | ||||
|  | ||||
|         Course progra1 = new Course(5,"Programmation et algorithmique 1",joke); | ||||
|         Course chemistry1 = new Course(12, "Thermochimie",joke); | ||||
|         Course psycho1 = new Course(21, "Neuroreaction of isolated brain cells",joke); | ||||
|         Course commun = new Course(2, "cours commun",joke); | ||||
|             InscriptionRequest inscriptionRequest = new InscriptionRequest("helen", "prenom", "non", "helen@gmail.com", "america", new Date(), (long) 4, RequestState.Pending, "yes.png", "password", null, new Date(), RequestState.Pending); | ||||
|  | ||||
|         courseService.save(progra1); | ||||
|         courseService.save(chemistry1); | ||||
|         courseService.save(psycho1); | ||||
|         courseService.save(commun); | ||||
|             inscriptionService.save(inscriptionRequest); | ||||
|             ExternalCurriculum externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null); | ||||
|             externalCurriculumRepository.save(externalCurriculum); | ||||
|  | ||||
|             /////////////////////////// | ||||
|             // extension Publications Scientifiques | ||||
|             Researcher jojoResearcherAccount = new Researcher(jojo, "3363-22555-AB33-T", null, "IT"); | ||||
|  | ||||
|             Researcher output = researchesService.saveResearcher(jojoResearcherAccount); | ||||
|  | ||||
|             Research jojoResearch = new Research("Graphs : Advanced Search Algorithms", output, new Date(0), | ||||
|                     PaperType.Article, "here.pdf", null, "english", | ||||
|                     Access.OpenSource, "IT", "This Article's title speaks for itself \n We'll discuss about advanced Graph search Algorithms"); | ||||
|  | ||||
|             Research restrictedResearch = new Research("just another Name", output, new Date(1111111111), | ||||
|                     PaperType.Article, "restricted", null, "english", | ||||
|                     Access.Restricted, "Restricted", "This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms"); | ||||
|  | ||||
|             Research privateResearch = new Research("the great Potato War", output, new Date(), | ||||
|                     PaperType.Article, "private", null, "english", | ||||
|                     Access.Private, "private", "This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms"); | ||||
|  | ||||
|  | ||||
|         CurriculumCourseService.save(new CurriculumCourse(infoBab1,progra1)); | ||||
|         CurriculumCourseService.save(new CurriculumCourse(infoBab1,commun)); | ||||
|             researchesService.saveResearch(restrictedResearch); | ||||
|             researchesService.saveResearch(privateResearch); | ||||
|  | ||||
|         CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,psycho1)); | ||||
|         CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,commun)); | ||||
|             researchesService.saveResearch(jojoResearch); | ||||
|  | ||||
|  | ||||
|         CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,commun)); | ||||
|         CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1)); | ||||
|  | ||||
|  | ||||
|         InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 1,RequestState.Pending,"yes.png","password"); | ||||
|  | ||||
|         inscriptionService.save(inscriptionRequest); | ||||
|  | ||||
|  | ||||
|         /////////////////////////// | ||||
|         // extension Publications Scientifiques | ||||
|         Researcher jojoResearcherAccount = new Researcher(jojo,"3363-22555-AB33-T",null,"IT"); | ||||
|  | ||||
|         Researcher output = researchesService.saveResearcher(jojoResearcherAccount); | ||||
|  | ||||
|         Research jojoResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(0), | ||||
|                 PaperType.Article,"here.pdf",null,"english", | ||||
|                 Access.OpenSource,"IT","This Article's title speaks for itself \n We'll discuss about advanced Graph search Algorithms"); | ||||
|  | ||||
|         Research restrictedResearch = new Research("just another Name",output,new Date(1111111111), | ||||
|                 PaperType.Article,"restricted",null,"english", | ||||
|                 Access.Restricted,"Restricted","This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms"); | ||||
|  | ||||
|         Research privateResearch = new Research("the great Potato War",output,new Date(), | ||||
|                 PaperType.Article,"private",null,"english", | ||||
|                 Access.Private,"private","This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms"); | ||||
|  | ||||
|  | ||||
|         researchesService.saveResearch(restrictedResearch); | ||||
|         researchesService.saveResearch(privateResearch); | ||||
|  | ||||
|         researchesService.saveResearch(jojoResearch); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -1,37 +0,0 @@ | ||||
| package ovh.herisson.Clyde; | ||||
|  | ||||
| import javax.sql.DataSource; | ||||
|  | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.context.annotation.Profile; | ||||
| import org.springframework.jdbc.datasource.DriverManagerDataSource; | ||||
| import org.springframework.scheduling.annotation.EnableScheduling; | ||||
|  | ||||
| @Configuration | ||||
| @EnableScheduling | ||||
| public class JdbcConfig { | ||||
|  | ||||
| 	@Bean | ||||
| 	@Profile("!prod") | ||||
| 	public DataSource psqlSource(){ | ||||
| 		DriverManagerDataSource source = new DriverManagerDataSource(); | ||||
| 		source.setDriverClassName("org.postgresql.Driver"); | ||||
| 		source.setUrl("jdbc:postgresql://localhost:5442/clyde"); | ||||
| 		source.setUsername("devel"); | ||||
| 		source.setPassword("devel"); | ||||
|  | ||||
| 		return source; | ||||
| 	} | ||||
|  | ||||
| 	@Bean | ||||
| 	@Profile("prod") | ||||
| 	public DataSource psqlSourceProd(){ | ||||
| 		DriverManagerDataSource source = new DriverManagerDataSource(); | ||||
| 		source.setDriverClassName("org.postgresql.Driver"); | ||||
| 		source.setUrl("jdbc:postgresql:clyde?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"); | ||||
| 		source.setUsername("clyde"); | ||||
|  | ||||
| 		return source; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,8 @@ | ||||
| package ovh.herisson.Clyde.Repositories.Inscription; | ||||
|  | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; | ||||
|  | ||||
| public interface ExemptionsRequestRepository extends CrudRepository<ExemptionsRequest, Long> { | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package ovh.herisson.Clyde.Repositories.Inscription; | ||||
|  | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| public interface ExternalCurriculumRepository extends CrudRepository<ExternalCurriculum, Long> { | ||||
|     ArrayList<ExternalCurriculum> getExternalCurriculumByInscriptionRequest(InscriptionRequest ir); | ||||
|  | ||||
|     ArrayList<ExternalCurriculum> getExternalCurriculumByUser(User user); | ||||
|     ExternalCurriculum getExternalCurriculumById(long id); | ||||
| } | ||||
| @ -1,7 +1,7 @@ | ||||
| package ovh.herisson.Clyde.Repositories; | ||||
| package ovh.herisson.Clyde.Repositories.Inscription; | ||||
| 
 | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| 
 | ||||
| 
 | ||||
| public interface InscriptionRepository extends CrudRepository<InscriptionRequest,Long> { | ||||
| @ -0,0 +1,12 @@ | ||||
| package ovh.herisson.Clyde.Repositories.Inscription; | ||||
|  | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.Minerval; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| public interface MinervalRepository extends CrudRepository<Minerval, Long> { | ||||
|     public ArrayList<Minerval> getMinervalsByStudentRegNoOrderByYearDesc(Long studentRegNo); | ||||
|  | ||||
|     public Minerval findById(long id); | ||||
| } | ||||
| @ -0,0 +1,10 @@ | ||||
| package ovh.herisson.Clyde.Repositories.Inscription; | ||||
|  | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.Payment; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| public interface PaymentRepository extends CrudRepository<Payment, Long> { | ||||
|     public ArrayList<Payment> getPaymentsByStudentRegNo(long regNo); | ||||
| } | ||||
| @ -0,0 +1,8 @@ | ||||
| package ovh.herisson.Clyde.Repositories.Inscription; | ||||
|  | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; | ||||
|  | ||||
| public interface ScholarshipRequestRepository extends CrudRepository<ScholarshipRequest, Long> { | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,7 @@ | ||||
| package ovh.herisson.Clyde.Repositories.Inscription; | ||||
|  | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest; | ||||
|  | ||||
| public interface UninscriptionRequestRepository extends CrudRepository<UninscriptionRequest, Long> { | ||||
| } | ||||
| @ -6,8 +6,12 @@ import ovh.herisson.Clyde.Tables.Curriculum; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
| import ovh.herisson.Clyde.Tables.UserCurriculum; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| public interface UserCurriculumRepository extends CrudRepository<UserCurriculum, Long> { | ||||
|  | ||||
|     @Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1") | ||||
|     Curriculum findByUser(User student); | ||||
|  | ||||
|     ArrayList<UserCurriculum> findByUserOrderByCurriculum(User student); | ||||
| } | ||||
|  | ||||
| @ -1,7 +1,10 @@ | ||||
| package ovh.herisson.Clyde.Services; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import ovh.herisson.Clyde.Services.Inscription.InscriptionService; | ||||
| import ovh.herisson.Clyde.Tables.*; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| @Service | ||||
|  | ||||
| @ -18,7 +18,6 @@ public class CurriculumService { | ||||
|     public Curriculum findById(long id){ | ||||
|         return curriculumRepo.findById(id); | ||||
|     } | ||||
|  | ||||
|     public void delete(Curriculum curriculum) { | ||||
|         curriculumRepo.delete(curriculum); | ||||
|     } | ||||
|  | ||||
| @ -0,0 +1,105 @@ | ||||
| package ovh.herisson.Clyde.Services.Inscription; | ||||
|  | ||||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||||
| import org.springframework.stereotype.Service; | ||||
| import ovh.herisson.Clyde.Repositories.*; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository; | ||||
| import ovh.herisson.Clyde.Tables.*; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.Minerval; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| @Service | ||||
| public class InscriptionService { | ||||
|  | ||||
|     private final InscriptionRepository inscriptionRepo; | ||||
|  | ||||
|     private final UserRepository userRepo; | ||||
|  | ||||
|     private final UserCurriculumRepository userCurriculumRepo; | ||||
|  | ||||
|     private final CurriculumRepository curriculumRepo; | ||||
|  | ||||
|     private final MinervalRepository minervalRepository; | ||||
|     private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | ||||
|     private final ExternalCurriculumRepository externalCurriculumRepository; | ||||
|  | ||||
|     public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo, MinervalRepository minervalRepository, ExternalCurriculumRepository externalCurriculumRepository){ | ||||
|         this.inscriptionRepo = inscriptionRepo; | ||||
|         this.userRepo = userRepo; | ||||
|         this.userCurriculumRepo = userCurriculumRepo; | ||||
|         this.curriculumRepo = curriculumRepo; | ||||
|         this.minervalRepository = minervalRepository; | ||||
|         this.externalCurriculumRepository = externalCurriculumRepository; | ||||
|     } | ||||
|  | ||||
|     public InscriptionRequest save(InscriptionRequest inscriptionRequest){ | ||||
|         inscriptionRequest.setPassword(passwordEncoder.encode(inscriptionRequest.getPassword())); | ||||
|         return inscriptionRepo.save(inscriptionRequest); | ||||
|     } | ||||
|  | ||||
|     public InscriptionRequest getById(long id){ | ||||
|         return inscriptionRepo.findById(id); | ||||
|     } | ||||
|  | ||||
|     public Iterable<InscriptionRequest> getAll(){ | ||||
|         return inscriptionRepo.findAll(); | ||||
|     } | ||||
|  | ||||
|     public boolean modifyState(long id, RequestState requestState) { | ||||
|         InscriptionRequest inscrRequest = getById(id); | ||||
|  | ||||
|         if (inscrRequest == null) | ||||
|             return false; | ||||
|  | ||||
|         inscrRequest.setState(requestState); | ||||
|         save(inscrRequest); | ||||
|  | ||||
|         //saves the user from the request if accepted from teacher and inscription services | ||||
|         if (requestState == RequestState.Accepted && (inscrRequest.getEquivalenceState() == RequestState.Accepted || inscrRequest.getEquivalenceState() == RequestState.Unrequired)) | ||||
|         { | ||||
|             return createUser(inscrRequest); | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     public boolean createUser(InscriptionRequest inscrRequest){ | ||||
|         //We must send an email here | ||||
|  | ||||
|         if (curriculumRepo.findById(inscrRequest.getCurriculumId()) == null) | ||||
|             return false; | ||||
|  | ||||
|         User userFromRequest = new User( | ||||
|                 inscrRequest.getLastName(), | ||||
|                 inscrRequest.getFirstName(), | ||||
|                 inscrRequest.getEmail(), | ||||
|                 inscrRequest.getAddress(), | ||||
|                 inscrRequest.getCountry(), | ||||
|                 inscrRequest.getBirthDate(), | ||||
|                 inscrRequest.getProfilePicture(), | ||||
|                 inscrRequest.getPassword() | ||||
|         ); | ||||
|  | ||||
|         userRepo.save(userFromRequest); | ||||
|         userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0)); | ||||
|  | ||||
|         //Create a minerval for the new student | ||||
|         Minerval minerval = new Minerval(userFromRequest.getRegNo(), 0, 852, 2023); | ||||
|         minervalRepository.save(minerval); | ||||
|  | ||||
|         //Assign the externals curriculums from the inscription request to newly created student | ||||
|         ArrayList<ExternalCurriculum> extCurrList = externalCurriculumRepository.getExternalCurriculumByInscriptionRequest(inscrRequest); | ||||
|         for (int i = 0; i < extCurrList.size(); i++){ | ||||
|             extCurrList.get(i).setUser(userFromRequest); | ||||
|             externalCurriculumRepository.save(extCurrList.get(i)); | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|     public void delete(InscriptionRequest toDelete) { | ||||
|         inscriptionRepo.delete(toDelete); | ||||
|     } | ||||
| } | ||||
| @ -1,94 +0,0 @@ | ||||
| package ovh.herisson.Clyde.Services; | ||||
|  | ||||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||||
| import org.springframework.stereotype.Service; | ||||
| import ovh.herisson.Clyde.Repositories.CurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.InscriptionRepository; | ||||
| import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.UserRepository; | ||||
| import ovh.herisson.Clyde.Tables.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
| import ovh.herisson.Clyde.Tables.UserCurriculum; | ||||
|  | ||||
| @Service | ||||
| public class InscriptionService { | ||||
|  | ||||
|     private final InscriptionRepository inscriptionRepo; | ||||
|  | ||||
|     private final UserRepository userRepo; | ||||
|  | ||||
|     private final UserCurriculumRepository userCurriculumRepo; | ||||
|  | ||||
|     private final CurriculumRepository curriculumRepo; | ||||
|  | ||||
|     private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | ||||
|  | ||||
|  | ||||
|     public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo){ | ||||
|         this.inscriptionRepo = inscriptionRepo; | ||||
|         this.userRepo = userRepo; | ||||
|         this.userCurriculumRepo = userCurriculumRepo; | ||||
|         this.curriculumRepo = curriculumRepo; | ||||
|     } | ||||
|  | ||||
|     public InscriptionRequest save(InscriptionRequest inscriptionRequest){ | ||||
|         inscriptionRequest.setPassword(passwordEncoder.encode(inscriptionRequest.getPassword())); | ||||
|         return inscriptionRepo.save(inscriptionRequest); | ||||
|     } | ||||
|  | ||||
|     public InscriptionRequest getById(long id){ | ||||
|         return inscriptionRepo.findById(id); | ||||
|     } | ||||
|  | ||||
|     public Iterable<InscriptionRequest> getAll(){ | ||||
|         return inscriptionRepo.findAll(); | ||||
|     } | ||||
|  | ||||
|     public boolean modifyState(long id, RequestState requestState) { | ||||
|         InscriptionRequest inscrRequest = getById(id); | ||||
|  | ||||
|         if (inscrRequest == null) | ||||
|             return false; | ||||
|  | ||||
|         // if th state is the same we don't send an email | ||||
|         if (requestState == inscrRequest.getState()) | ||||
|             return false; | ||||
|  | ||||
|         /** todo send an email to tell the poster of the inscrRequest (inscrRequest.getEmail()) | ||||
|          *  to notify them that the state of their request changed | ||||
|          *  FooEmailFormat toSend = (String.format("Your request state changed from %s to %s"), | ||||
|          *                                              inscrRequest.getState(), requestState) | ||||
|          * FooEmailSender.send(toSend, inscrRequest.getEmail()) | ||||
|          */ | ||||
|  | ||||
|  | ||||
|         //saves the user from the request if accepted | ||||
|         if (requestState == RequestState.Accepted) | ||||
|         { | ||||
|             if (curriculumRepo.findById(inscrRequest.getCurriculumId()) == null) | ||||
|                 return false; | ||||
|  | ||||
|             User userFromRequest = new User( | ||||
|                     inscrRequest.getLastName(), | ||||
|                     inscrRequest.getFirstName(), | ||||
|                     inscrRequest.getEmail(), | ||||
|                     inscrRequest.getAddress(), | ||||
|                     inscrRequest.getCountry(), | ||||
|                     inscrRequest.getBirthDate(), | ||||
|                     inscrRequest.getProfilePicture(), | ||||
|                     inscrRequest.getPassword() | ||||
|             ); | ||||
|  | ||||
|             userRepo.save(userFromRequest); | ||||
|             userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()))); | ||||
|         } | ||||
|         inscrRequest.setState(requestState); | ||||
|         save(inscrRequest); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     public void delete(InscriptionRequest toDelete) { | ||||
|         inscriptionRepo.delete(toDelete); | ||||
|     } | ||||
| } | ||||
| @ -1,7 +1,7 @@ | ||||
| package ovh.herisson.Clyde.Services; | ||||
|  | ||||
| import ovh.herisson.Clyde.Tables.Course; | ||||
| import ovh.herisson.Clyde.Tables.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| @ -87,7 +87,9 @@ public class ProtectionService { | ||||
|         toReturn.put("curriculum", inscriptionRequest.getCurriculumId()); | ||||
|         toReturn.put("state", inscriptionRequest.getState()); | ||||
|         toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture()); | ||||
|  | ||||
|         toReturn.put("identityCard", inscriptionRequest.getIdentityCard()); | ||||
|         toReturn.put("submissionDate", inscriptionRequest.getSubmissionDate()); | ||||
|         toReturn.put("equivalenceState", inscriptionRequest.getEquivalenceState()); | ||||
|         return toReturn; | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -1,20 +1,52 @@ | ||||
| package ovh.herisson.Clyde.Services; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import ovh.herisson.Clyde.Repositories.CurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; | ||||
| import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; | ||||
| import ovh.herisson.Clyde.Tables.Curriculum; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
| import ovh.herisson.Clyde.Tables.*; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
|  | ||||
| @Service | ||||
| public class UserCurriculumService { | ||||
|  | ||||
|     private final UserCurriculumRepository userCurriculumRepository; | ||||
|     private final CurriculumRepository curriculumRepo; | ||||
|  | ||||
|     public UserCurriculumService(UserCurriculumRepository userCurriculumRepository) { | ||||
|     private final ExternalCurriculumRepository externalCurriculumRepo; | ||||
|     public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo, ExternalCurriculumRepository externalCurriculumRepo) { | ||||
|         this.userCurriculumRepository = userCurriculumRepository; | ||||
|         this.curriculumRepo = curriculumRepo; | ||||
|         this.externalCurriculumRepo = externalCurriculumRepo; | ||||
|     } | ||||
|  | ||||
|     public Curriculum findByUser(User student){ | ||||
|         return userCurriculumRepository.findByUser(student); | ||||
|     } | ||||
|  | ||||
|     public HashMap<String,Object> findAllCurriculumByStudent(User student) { | ||||
|         ArrayList<UserCurriculum> list = userCurriculumRepository.findByUserOrderByCurriculum(student); | ||||
|  | ||||
|         ArrayList<HashMap<String, Object>> curriculumlist = new ArrayList<HashMap<String, Object>>(); | ||||
|  | ||||
|         for (int i = 0; i < list.size(); i++) { | ||||
|             HashMap<String, Object> element = new HashMap<>(); | ||||
|             Curriculum c = list.get(i).getCurriculum(); | ||||
|  | ||||
|  | ||||
|             element.put("curriculumId", c.getCurriculumId()); | ||||
|             element.put("year", c.getYear()); | ||||
|             element.put("option", c.getOption()); | ||||
|             element.put("dateyear", list.get(i).getYear()); | ||||
|             curriculumlist.add(element); | ||||
|         } | ||||
|  | ||||
|         HashMap<String, Object> toReturn = new HashMap<String, Object>(); | ||||
|         toReturn.put("curriculumList", curriculumlist); | ||||
|         return toReturn; | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -18,6 +18,6 @@ public enum Applications { | ||||
|     UsersList, | ||||
|  | ||||
|     // InscriptionService authorization | ||||
|     Inscription, | ||||
|     Requests, | ||||
|     StudentsList | ||||
| } | ||||
|  | ||||
| @ -1,10 +1,8 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| public enum FileType { | ||||
|  | ||||
|     ProfilePicture, | ||||
|  | ||||
|     EducationCertificate, | ||||
|  | ||||
|     Article, | ||||
|     JustificationDocument | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,83 @@ | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
|  | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
| import org.hibernate.annotations.OnDelete; | ||||
| import org.hibernate.annotations.OnDeleteAction; | ||||
| import ovh.herisson.Clyde.Tables.Course; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| @Entity | ||||
| public class ExemptionsRequest { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int id; | ||||
|  | ||||
|     @JoinColumn(name = "Users") | ||||
|     @ManyToOne(fetch = FetchType.EAGER) | ||||
|     private User user; | ||||
|  | ||||
|     @JoinColumn(name = "Course") | ||||
|     @ManyToOne(fetch = FetchType.EAGER) | ||||
|     private Course course; | ||||
|     private String justifDocument; | ||||
|  | ||||
|     private RequestState state; | ||||
|  | ||||
|     private Date date; | ||||
|  | ||||
|     public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state, Date date){ | ||||
|         this.user = user; | ||||
|         this.course = course; | ||||
|         this.justifDocument = justifDocument; | ||||
|         this.state = state; | ||||
|         this.date = date; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public ExemptionsRequest(){} | ||||
|  | ||||
|     public User getUser() { | ||||
|         return user; | ||||
|     } | ||||
|  | ||||
|     public void setUser(User user) { | ||||
|         this.user = user; | ||||
|     } | ||||
|  | ||||
|     public Course getCourse() { | ||||
|         return course; | ||||
|     } | ||||
|  | ||||
|     public void setCourse(Course course) { | ||||
|         this.course = course; | ||||
|     } | ||||
|  | ||||
|     public String getJustifDocument() { | ||||
|         return justifDocument; | ||||
|     } | ||||
|  | ||||
|     public void setJustifDocument(String justifDocument) { | ||||
|         this.justifDocument = justifDocument; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public RequestState getState() { | ||||
|         return state; | ||||
|     } | ||||
|  | ||||
|     public void setState(RequestState state) { | ||||
|         this.state = state; | ||||
|     } | ||||
|  | ||||
|     public Date getDate() { | ||||
|         return date; | ||||
|     } | ||||
|  | ||||
|     public void setDate(Date date) { | ||||
|         this.date = date; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,114 @@ | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
|  | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| //This table stores a student's curriculum from another university | ||||
| @Entity | ||||
| public class ExternalCurriculum { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int id; | ||||
|  | ||||
|     //An external curriculum is first linked to an inscription request and when it is accepted and the user is created we link it to the user | ||||
|     @ManyToOne(fetch = FetchType.EAGER) | ||||
|     @JoinColumn(name="InscriptionRequest") | ||||
|     private InscriptionRequest inscriptionRequest; | ||||
|  | ||||
|     @ManyToOne(fetch = FetchType.EAGER) | ||||
|     @JoinColumn(name="Users") | ||||
|     private User user; | ||||
|  | ||||
|     private String school; | ||||
|  | ||||
|     private String formation; | ||||
|  | ||||
|     //This string denotes the completion of the external formation or the last year completed by the student in this formation | ||||
|     private String completion; | ||||
|  | ||||
|     private int startYear; | ||||
|     private int endYear; | ||||
|     private String justifdocUrl; | ||||
|  | ||||
|     public ExternalCurriculum(){} | ||||
|  | ||||
|     public ExternalCurriculum(InscriptionRequest ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl,User user){ | ||||
|         this.inscriptionRequest = ir; | ||||
|         this.school = school; | ||||
|         this.formation = formation; | ||||
|         this.completion = completion; | ||||
|         this.startYear = startYear; | ||||
|         this.endYear = endYear; | ||||
|         this.justifdocUrl = justifdocUrl; | ||||
|         this.user = user; | ||||
|     } | ||||
|  | ||||
|     public int getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public InscriptionRequest getInscriptionRequest() { | ||||
|         return inscriptionRequest; | ||||
|     } | ||||
|  | ||||
|     public void setInscriptionRequest(InscriptionRequest inscriptionRequest) { | ||||
|         this.inscriptionRequest = inscriptionRequest; | ||||
|     } | ||||
|  | ||||
|     public String getSchool() { | ||||
|         return school; | ||||
|     } | ||||
|  | ||||
|     public void setSchool(String school) { | ||||
|         this.school = school; | ||||
|     } | ||||
|  | ||||
|     public String getFormation() { | ||||
|         return formation; | ||||
|     } | ||||
|  | ||||
|     public void setFormation(String formation) { | ||||
|         this.formation = formation; | ||||
|     } | ||||
|  | ||||
|     public String getCompletion(){ | ||||
|         return completion; | ||||
|     } | ||||
|  | ||||
|     public void setCompletion(String completion) { | ||||
|         this.completion = completion; | ||||
|     } | ||||
|  | ||||
|     public int getStartYear() { | ||||
|         return startYear; | ||||
|     } | ||||
|  | ||||
|     public void setStartYear(int startYear) { | ||||
|         this.startYear = startYear; | ||||
|     } | ||||
|  | ||||
|     public int getEndYear() { | ||||
|         return endYear; | ||||
|     } | ||||
|  | ||||
|     public void setEndYear(int endYear) { | ||||
|         this.endYear = endYear; | ||||
|     } | ||||
|  | ||||
|     public void setJustifdocUrl(String justifdocUrl) { | ||||
|         this.justifdocUrl = justifdocUrl; | ||||
|     } | ||||
|  | ||||
|     public String getJustifdocUrl() { | ||||
|         return justifdocUrl; | ||||
|     } | ||||
|  | ||||
|     public void setUser(User user) { | ||||
|         this.user = user; | ||||
|     } | ||||
|  | ||||
|     public User getUser() { | ||||
|         return user; | ||||
|     } | ||||
| } | ||||
| @ -1,6 +1,8 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
| 
 | ||||
| import jakarta.persistence.*; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| 
 | ||||
| @ -15,14 +17,16 @@ public class InscriptionRequest { | ||||
|     private String email; | ||||
|     private String country; | ||||
|     private Date birthDate; | ||||
| 
 | ||||
|     private Long curriculumId; | ||||
|     private RequestState state; | ||||
|     private String profilePicture; | ||||
| 
 | ||||
|     private String password; | ||||
|     private String identityCard; | ||||
|     private Date submissionDate; | ||||
|     private RequestState equivalenceState; | ||||
|     public InscriptionRequest(){} | ||||
|     public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password){ | ||||
| 
 | ||||
|     public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password, String identityCard, Date submissionDate, RequestState equivalenceState){ | ||||
|         this.lastName = lastName; | ||||
|         this.firstName = firstName; | ||||
|         this.address = address; | ||||
| @ -33,6 +37,9 @@ public class InscriptionRequest { | ||||
|         this.state = state; | ||||
|         this.profilePicture = profilePicture; | ||||
|         this.password = password; | ||||
|         this.identityCard = identityCard; | ||||
|         this.submissionDate = submissionDate; | ||||
|         this.equivalenceState = equivalenceState; | ||||
|     } | ||||
| 
 | ||||
|     public int getId() { | ||||
| @ -118,4 +125,28 @@ public class InscriptionRequest { | ||||
|     public void setPassword(String password) { | ||||
|         this.password = password; | ||||
|     } | ||||
| 
 | ||||
|     public String getIdentityCard() { | ||||
|         return identityCard; | ||||
|     } | ||||
| 
 | ||||
|     public void setIdentityCard(String identityCard) { | ||||
|         this.identityCard = identityCard; | ||||
|     } | ||||
| 
 | ||||
|     public Date getSubmissionDate() { | ||||
|         return submissionDate; | ||||
|     } | ||||
| 
 | ||||
|     public void setSubmissionDate(Date submissionDate) { | ||||
|         this.submissionDate = submissionDate; | ||||
|     } | ||||
| 
 | ||||
|     public RequestState getEquivalenceState() { | ||||
|         return equivalenceState; | ||||
|     } | ||||
| 
 | ||||
|     public void setEquivalenceState(RequestState equivalenceState) { | ||||
|         this.equivalenceState = equivalenceState; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,64 @@ | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
|  | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.GeneratedValue; | ||||
| import jakarta.persistence.GenerationType; | ||||
| import jakarta.persistence.Id; | ||||
|  | ||||
| @Entity | ||||
| public class Minerval { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private long id; | ||||
|  | ||||
|     private long studentRegNo; | ||||
|     private int paidAmount; | ||||
|     private int toPay; | ||||
|  | ||||
|     //If the academic year is 2023-2024 then 2023 will be stored here (we take the lowest year) | ||||
|     private int year; | ||||
|     public Minerval(){} | ||||
|  | ||||
|     public Minerval(long studentRegNo, int paidAmount, int toPay, int year){ | ||||
|         this.studentRegNo = studentRegNo; | ||||
|         this.paidAmount = paidAmount; | ||||
|         this.toPay = toPay; | ||||
|         this.year = year; | ||||
|     } | ||||
|  | ||||
|     public long getStudentRegNo() { | ||||
|         return studentRegNo; | ||||
|     } | ||||
|  | ||||
|     public void setStudentRegNo(long studentRegNo) { | ||||
|         this.studentRegNo = studentRegNo; | ||||
|     } | ||||
|  | ||||
|     public int getPaidAmount() { | ||||
|         return paidAmount; | ||||
|     } | ||||
|  | ||||
|     public void setPaidAmount(int paidAmount) { | ||||
|         this.paidAmount = paidAmount; | ||||
|     } | ||||
|  | ||||
|     public int getToPay() { | ||||
|         return toPay; | ||||
|     } | ||||
|  | ||||
|     public void setToPay(int toPay) { | ||||
|         this.toPay = toPay; | ||||
|     } | ||||
|  | ||||
|     public int getYear() { | ||||
|         return year; | ||||
|     } | ||||
|  | ||||
|     public void setYear(int year) { | ||||
|         this.year = year; | ||||
|     } | ||||
|  | ||||
|     public long getId() { | ||||
|         return id; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,84 @@ | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
|  | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.GeneratedValue; | ||||
| import jakarta.persistence.GenerationType; | ||||
| import jakarta.persistence.Id; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| @Entity | ||||
| public class Payment { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private long id; | ||||
|  | ||||
|     private long studentRegNo; | ||||
|     private String card; | ||||
|     private String client; | ||||
|     private Date expDate; | ||||
|     private int amount; | ||||
|     private Date date; | ||||
|     public Payment(){} | ||||
|  | ||||
|     public Payment(long studentRegNo, String card, String client, Date expDate, int amount, Date date){ | ||||
|         this.studentRegNo = studentRegNo; | ||||
|         this.card = card; | ||||
|         this.client = client; | ||||
|         this.expDate = expDate; | ||||
|         this.amount = amount; | ||||
|         this.date = date; | ||||
|     } | ||||
|  | ||||
|     public long getStudentRegNo() { | ||||
|         return studentRegNo; | ||||
|     } | ||||
|  | ||||
|     public void setStudentRegNo(long studentRegNo) { | ||||
|         this.studentRegNo = studentRegNo; | ||||
|     } | ||||
|  | ||||
|     public String getCard() { | ||||
|         return card; | ||||
|     } | ||||
|  | ||||
|     public void setCard(String card) { | ||||
|         this.card = card; | ||||
|     } | ||||
|  | ||||
|     public String getClient() { | ||||
|         return client; | ||||
|     } | ||||
|  | ||||
|     public void setClient(String client) { | ||||
|         this.client = client; | ||||
|     } | ||||
|  | ||||
|     public Date getExpDate() { | ||||
|         return expDate; | ||||
|     } | ||||
|  | ||||
|     public void setExpDate(Date expDate) { | ||||
|         this.expDate = expDate; | ||||
|     } | ||||
|  | ||||
|     public int getAmount() { | ||||
|         return amount; | ||||
|     } | ||||
|  | ||||
|     public void setAmount(int amount) { | ||||
|         this.amount = amount; | ||||
|     } | ||||
|  | ||||
|     public long getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public Date getDate() { | ||||
|         return date; | ||||
|     } | ||||
|  | ||||
|     public void setDate(Date date) { | ||||
|         this.date = date; | ||||
|     } | ||||
| } | ||||
| @ -1,8 +1,11 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
| 
 | ||||
| import jakarta.persistence.*; | ||||
| import org.hibernate.annotations.OnDelete; | ||||
| import org.hibernate.annotations.OnDeleteAction; | ||||
| import ovh.herisson.Clyde.Tables.Curriculum; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
| 
 | ||||
| @Entity | ||||
| public class ReInscriptionRequest { | ||||
| @ -0,0 +1,88 @@ | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
| import org.hibernate.annotations.OnDelete; | ||||
| import org.hibernate.annotations.OnDeleteAction; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| @Entity | ||||
| public class ScholarshipRequest { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private long id; | ||||
|  | ||||
|     @JoinColumn(name="Users") | ||||
|     @ManyToOne(fetch = FetchType.EAGER) | ||||
|     private User user; | ||||
|     private RequestState state; | ||||
|     private Date date; | ||||
|     private int amount; | ||||
|     private String taxDocUrl; | ||||
|     private String residencyDocUrl; | ||||
|  | ||||
|     public ScholarshipRequest(User user, RequestState state, int amount, Date date, String taxDocUrl, String residencyDocUrl){ | ||||
|         this.user = user; | ||||
|         this.state = state; | ||||
|         this.amount = amount; | ||||
|         this.date = date; | ||||
|         this.taxDocUrl = taxDocUrl; | ||||
|         this.residencyDocUrl = residencyDocUrl; | ||||
|     } | ||||
|  | ||||
|     public ScholarshipRequest(){} | ||||
|  | ||||
|     public User getUser() { | ||||
|         return user; | ||||
|     } | ||||
|  | ||||
|     public void setUser(User user) { | ||||
|         this.user = user; | ||||
|     } | ||||
|  | ||||
|     public RequestState getState() { | ||||
|         return state; | ||||
|     } | ||||
|  | ||||
|     public void setState(RequestState state) { | ||||
|         this.state = state; | ||||
|     } | ||||
|  | ||||
|     public int getAmount() { | ||||
|         return amount; | ||||
|     } | ||||
|  | ||||
|     public void setAmount(int amount) { | ||||
|         this.amount = amount; | ||||
|     } | ||||
|  | ||||
|     public Date getDate() { | ||||
|         return date; | ||||
|     } | ||||
|  | ||||
|     public void setDate(Date date) { | ||||
|         this.date = date; | ||||
|     } | ||||
|  | ||||
|     public long getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public String getResidencyDocUrl() { | ||||
|         return residencyDocUrl; | ||||
|     } | ||||
|  | ||||
|     public void setResidencyDocUrl(String residencyDocUrl) { | ||||
|         this.residencyDocUrl = residencyDocUrl; | ||||
|     } | ||||
|  | ||||
|     public String getTaxDocUrl() { | ||||
|         return taxDocUrl; | ||||
|     } | ||||
|  | ||||
|     public void setTaxDocUrl(String taxDocUrl) { | ||||
|         this.taxDocUrl = taxDocUrl; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,67 @@ | ||||
| package ovh.herisson.Clyde.Tables.Inscription; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| @Entity | ||||
| public class UninscriptionRequest { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private long id; | ||||
|     private RequestState state; | ||||
|     private String reason; | ||||
|     private Date date; | ||||
|  | ||||
|     @JoinColumn(name = "Users") | ||||
|     @ManyToOne(fetch = FetchType.EAGER) | ||||
|     private User user; | ||||
|  | ||||
|     public UninscriptionRequest(RequestState state,String reason, Date date, User user){ | ||||
|         this.state = state; | ||||
|         this.reason = reason; | ||||
|         this.date = date; | ||||
|         this.user = user; | ||||
|     } | ||||
|  | ||||
|     public UninscriptionRequest(){} | ||||
|  | ||||
|     public RequestState getState() { | ||||
|         return state; | ||||
|     } | ||||
|  | ||||
|     public void setState(RequestState state) { | ||||
|         this.state = state; | ||||
|     } | ||||
|  | ||||
|     public String getReason() { | ||||
|         return reason; | ||||
|     } | ||||
|  | ||||
|     public void setReason(String reason) { | ||||
|         this.reason = reason; | ||||
|     } | ||||
|  | ||||
|     public long getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public User getUser() { | ||||
|         return user; | ||||
|     } | ||||
|  | ||||
|     public void setUser(User user) { | ||||
|         this.user = user; | ||||
|     } | ||||
|  | ||||
|     public void setDate(Date date) { | ||||
|         this.date = date; | ||||
|     } | ||||
|  | ||||
|     public Date getDate() { | ||||
|         return date; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -3,5 +3,6 @@ package ovh.herisson.Clyde.Tables; | ||||
| public enum RequestState { | ||||
|     Accepted, | ||||
|     Refused, | ||||
|     Pending | ||||
|     Pending, | ||||
|     Unrequired | ||||
| } | ||||
|  | ||||
| @ -21,9 +21,12 @@ public class UserCurriculum { | ||||
|     @OnDelete(action = OnDeleteAction.CASCADE) | ||||
|     private Curriculum curriculum; | ||||
|  | ||||
|     public UserCurriculum(User user, Curriculum curriculum){ | ||||
|     private int year; | ||||
|  | ||||
|     public UserCurriculum(User user, Curriculum curriculum, int year){ | ||||
|         this.user = user; | ||||
|         this.curriculum = curriculum; | ||||
|         this.year = year; | ||||
|     } | ||||
|  | ||||
|     public UserCurriculum() {} | ||||
| @ -47,4 +50,12 @@ public class UserCurriculum { | ||||
|     public void setCurriculum(Curriculum curriculum) { | ||||
|         this.curriculum = curriculum; | ||||
|     } | ||||
|  | ||||
|     public int getYear() { | ||||
|         return year; | ||||
|     } | ||||
|  | ||||
|     public void setYear(int year) { | ||||
|         this.year = year; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,3 +1,12 @@ | ||||
| spring.jpa.hibernate.ddl-auto=create-drop | ||||
| spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect | ||||
| spring.sql.init.mode=always | ||||
| spring.sql.init.mode=always | ||||
|  | ||||
| # spring.datasource.url=jdbc:postgresql://localhost:5442/clyde | ||||
| spring.datasource.url=jdbc:postgresql://db:5432/clyde | ||||
| spring.datasource.username=devel | ||||
| spring.datasource.password=devel | ||||
|  | ||||
| # spring.config.activate.on-profile=prod | ||||
| # spring.datasource.url=jdbc:postgresql:clyde?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432 | ||||
| # spring.datasource.username=clyde | ||||
|  | ||||
		Reference in New Issue
	
	Block a user