From 5808be72e1b9a2fc4d74c743427bd1d7171b32c9 Mon Sep 17 00:00:00 2001 From: Gabriel Alonso Varela Date: Wed, 15 Jan 2025 13:49:43 +0100 Subject: [PATCH] Tutor repared --- .../src/main/ngx/src/assets/i18n/en.json | 4 ++-- .../src/main/ngx/src/assets/i18n/es.json | 3 ++- .../cd2024bfs4g1/model/core/service/TutorTypeService.java | 7 +++++++ .../resources/db/migration/V46__repare_tutors_type.sql | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 cd2024bfs4g1-model/src/main/resources/db/migration/V46__repare_tutors_type.sql diff --git a/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/en.json b/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/en.json index bc71c2974..977b97f3e 100644 --- a/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/en.json +++ b/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/en.json @@ -385,11 +385,11 @@ "festivos":"Holidays", "holiday_date":"Holiday date", "REQ_LHOLIDAY_DATE":"Holiday date*", - "students_summary": "Students", "AsignarBoot" : "Assign bootcamps", "StudentLaboralStat" : "Student laboral status", "NewNote" : "New note", "Note" : "Note", "Session" : "Session", - "AcaData" : "Academic data" + "AcaData" : "Academic data", + "NOT_DELETABLE_TUTOR_TYPE_IS_DEFAULT": "The default mentor type cannot be deleted" } diff --git a/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/es.json b/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/es.json index 890099b24..9c428eb51 100644 --- a/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/es.json +++ b/cd2024bfs4g1-frontend/src/main/ngx/src/assets/i18n/es.json @@ -388,6 +388,7 @@ "LHOLIDAYS":"GestiĆ³n de festivos", "festivos":"Holidays", "holiday_date":"Fecha del festivo", - "REQ_LHOLIDAY_DATE":"Fecha del festivo*" + "REQ_LHOLIDAY_DATE":"Fecha del festivo*", + "NOT_DELETABLE_TUTOR_TYPE_IS_DEFAULT": "El tipo de tutor que quieres eliminar es el por defecto" } diff --git a/cd2024bfs4g1-model/src/main/java/com/campusdual/cd2024bfs4g1/model/core/service/TutorTypeService.java b/cd2024bfs4g1-model/src/main/java/com/campusdual/cd2024bfs4g1/model/core/service/TutorTypeService.java index d9205f37b..1b757e5d3 100644 --- a/cd2024bfs4g1-model/src/main/java/com/campusdual/cd2024bfs4g1/model/core/service/TutorTypeService.java +++ b/cd2024bfs4g1-model/src/main/java/com/campusdual/cd2024bfs4g1/model/core/service/TutorTypeService.java @@ -63,6 +63,13 @@ public EntityResult tutorTypeUpdate(Map attrMap, Map keyMap) throws OntimizeJEERuntimeException { try { + Integer id = (Integer) keyMap.get("id"); + if (id <= 2){ + EntityResult error = new EntityResultMapImpl(); + error.setMessage("NOT_DELETABLE_TUTOR_TYPE_IS_DEFAULT"); + error.setCode(EntityResult.OPERATION_WRONG); + return error; + } return this.daoHelper.delete(this.tutorTypeDao, keyMap); } catch (DataIntegrityViolationException e) { EntityResult error = new EntityResultMapImpl(); diff --git a/cd2024bfs4g1-model/src/main/resources/db/migration/V46__repare_tutors_type.sql b/cd2024bfs4g1-model/src/main/resources/db/migration/V46__repare_tutors_type.sql new file mode 100644 index 000000000..e44e0bcc5 --- /dev/null +++ b/cd2024bfs4g1-model/src/main/resources/db/migration/V46__repare_tutors_type.sql @@ -0,0 +1,8 @@ + +DELETE FROM public.tutors_type WHERE id IN (1,2); + +INSERT INTO public.tutors_type (id, "type") VALUES(1, 'Titular'); +INSERT INTO public.tutors_type (id, "type") VALUES(2, 'Apoyo'); + +ALTER TABLE tutor_bootcamp + ADD CONSTRAINT fk_tutor_type_bootcamp FOREIGN KEY (tutor_type) REFERENCES tutors_type(id); \ No newline at end of file