teammates
teammates copied to clipboard
[#13320] Refactoring data deletion logic to enhance maintainability and debugging
Fixes #13320
**Outline of Solution
- Successfully completed deletion method refactoring, consolidating deletion methods from multiple Logic classes into DeletionService.
- Reworked soft-delete methods into Db classes that did not already contain them.
- Successfully completed all modifications related to deletion preview as required by the proposal.
Modified Classes:
- DeletionService.java (created)
- Unified entry point for all deletion operations
- DeletionPreviewData.java
- Core data model, including:
- Entity type and identifier
- Count of affected entities (courses, students, instructors, feedback sessions, etc.)
- Warning messages list
- Cascaded deletion information
- Critical flags (whether last instructor, whether will orphan course, etc.)
- DeletionPreviewService.java
- Deletion preview service, providing the following preview methods:
- previewCourseDeletion() - Preview course deletion
- previewStudentDeletion() - Preview student deletion
- previewInstructorDeletion() - Preview instructor deletion
- previewAccountDeletion() - Preview account deletion
- previewAccountRequestDeletion() - Preview account request deletion
- previewNotificationDeletion() - Preview notification deletion
- LogicStarter.java
- Initialises DeletionService.java and DeletionPreviewService.java.
- _Logic classes
- Refactored Deletion methods into DeletionService.java, including:
- AccountRequestsLogic.java
- AccountsLogic.java
- CoursesLogic.java
- DataBundleLogic.java
- DeadlineExtensionsLogic.java
- FeedbackQuestionsLogic.java
- FeedbackResponseCommentsLogic.java
- FeedbackResponsesLogic.java
- InstructorsLogic.java
- NotificationsLogic.java
- StudentsLogic.java
- _Db classes
- Added softDelete_() and restoreDeleted_() methods, including:
- AccountRequestsDb.java
- AccountsDb.java
- DeadlineExtensionsDb.java
- FeedbackQuestionsDb.java
- FeedbackResponseCommentsDb.java
- FeedbackResponsesDb.java
- InstructorsDb.java
- NotificationsDb.java
- StudentsDb.java
- Entity classes & attribute classes
-
Added deletedAt Instant and relevant methods into:
- Entity classes in main/java/teammates/storage/entity/
- BaseEntity.java in main/java/teammates/storage/sqlentity/
- Atttribute classes in main/java/teammates/common/datatransfer/attributes/
-
Linked deletedAt Instants between corresponding entity/atttribute classes by editing valueOf().
- Database Layer Enhancements
- Added count methods to the following Db classes to support preview functionality:
- FeedbackSessionsDb: Added getFeedbackSessionsCountForCourse()
- FeedbackQuestionsDb: Added getFeedbackQuestionsCountForCourse()
- FeedbackResponsesDb: Added getFeedbackResponsesCountForCourse()
- FeedbackResponseCommentsDb: Added getFeedbackResponseCommentsCountForCourse()
- DeadlineExtensionsDb: Added getDeadlineExtensionsCountForCourse()
- API Endpoints Layer
- Created the following REST API endpoints:
- PreviewCourseDeletionAction - GET /webapi/course/deletion/preview
- PreviewStudentDeletionAction - GET /webapi/student/deletion/preview
- PreviewInstructorDeletionAction - GET /webapi/instructor/deletion/preview
- PreviewAccountDeletionAction - GET /webapi/account/deletion/preview
- Output Format
- DeletionPreviewOutput.java. API response format, containing:
- Statistics of all affected entities
- Warning messages
- Cascaded deletion details
- Well-structured data for frontend display
- Routing Configuration
- Added new URI constants in Const.java
- Registered all preview API endpoints in ActionFactory.java
- Initialized DeletionPreviewService.java dependencies in LogicStarter.java
- Created or modified basic test framework:
- DeletionServiceTest.java - Deletion service unit tests
- DeletionPreviewServiceTest.java - Service layer unit tests
- PreviewCourseDeletionActionTest.java - API endpoint test template
- _DbTest.java in test/java/teammates/storage/api/ - Soft delete unit tests
Hi @rainboh0622, thank you for your interest in contributing to TEAMMATES! However, your PR does not appear to follow our contribution guidelines:
- Title must start with the issue number the PR is fixing in square brackets, e.g.
[#<issue-number>]
Please address the above before we proceed to review your PR.
Update PR title to start with [#13320] (add a space between it and the rest of title?)