Repositories - THM-ATLAS/spring-backend GitHub Wiki

Overview

The repositories allow communication with the database.

The repository must be marked with the annotation '@Repository'.

Path

src/main/kotlin/com/example/atlasbackend/repository

Our repositories

Our repositories inherit from CrudRepository, which means they already provide some basic functionality.

To enable more functions, you can specify functions with the annotation @Query("...") a query, which is then executed on the database and returns data. If the query modifies data, such as INSERT, UPDATE, DELETE, the annotation @Modifying must also be specified.

To pass parameters to the query, you must specify the annotation @Param("name") with parameter names in the function arguments and then you can use them in the query with :name

AssetReposititory

Path

src/main/kotlin/com/example/atlasbackend/repository/AssetRepostitory.kt

functions

The AssetReposititory has no functions apart from the inherited crudRepository functions

ExerciseRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/ExerciseRepository.kt

functions

  • getExercisesByModule returns all exercises of the module , with input of the id of a module.
  • getExercisesByUser returns all exercises to which a user has access, with input of the id of a user.
  • getModuleByExercise returnsthe module to which a exercises belongs, with input of the id of a task.
  • loadPage returns a page of all exercises, with the input of a page-size and an offset.
  • getExercisesByUserByPage like getExercisesByUser but only returns a page of all tasks to which a user has access, with the input of a page-size and an offset.
  • getExercisesByModuleByPage like getExercisesByModule but only returns a page of all exercises of the module, with the input of a page-size and an offset.

ModuleRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/ModuleRepository.kt

functions

  • addUser adds a user with a role to a module, with the input of the id of the user module and role.
  • getUsersByModule returns all users of the module, with the input of the id of the module.
  • getModuleRoleByUser returns the role the user has in the module, with the input of the id of the user and module.
  • updateUserModuleRole edits the role of a user in a module, with the input of the id of the role user and module.
  • removeUser removes a user from a module, with the input of the id of the user and module.
  • loadPage returns a page of all modules, with the input of a page-size and an offset.

ModuleLinkRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/ModuleLinkRepository.kt

functions

  • getLinks returns all links of a module with the input of the module_id

ModuleAssetRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/ModuleAssetRepository.kt

functions

  • getAssets returns all Assets of a module with the input of the module_id

RatingRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/RatingRepository.kt

functions

  • getByExerciseId returns all the ratings of the task with the input of the id of the task.
  • getByUserId returns all the assessment of the user, with the input of the id of the user.
  • averageExerciseRating returns the average rating of the task, with the input of the Id of the task.

RoleRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/RoleRepository.kt

functions

  • getRolesByUser returns all the roles the user has, with the input of the id of the user.
  • giveRole adds a role to the user, with the input of the id of the user and the role.
  • removeRole removes the role of a user, with the input of the id of the user and the role.

SettingsRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/SettingsRepository.kt

functions

  • createSettings creates the settings of a user, with the input of the id of the user.

SubmissionRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/SubmissionRepository.kt

functions

  • loadPage returns a page of all submissions
  • getSubmissionsByExercise returns all submissions of a exercise, with the input the id of the exercise.
  • getSubmissionsByExerciseByPage returns a page of all submissions of a exercise, with the input the id of the exercise.
  • getSubmissionsByUser returns all submissions of a user, with the input of the id of a user.
  • getSubmissionsByUserByPage returns a page of all submissions of a user, with the input of the id of a user.
  • getExerciseSubmissionForUser returns a Submission of a user to an exercise

SubmissionTypeRepository

src/main/kotlin/com/example/atlasbackend/repository/SubmissionTypeRepository.kt

functions

The SubmissionTypeRepositoryhas no functions apart from the inherited crudRepository functions

CodeSubmissionRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/CodeSubmissionRepository.kt

funtions

  • insertCodeSubmission adds a code-Submission with the input of the submission_id, the content and the code-language

LanguageRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/LanguageRepository.kt

functions

The LanguageRepository has no functions apart from the inheritedcrudRepository functions

FileSubmissionRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/FileSubmissionRepository.kt

functions

FileSubmissionRepository has no functions apart from the inherited CrudRepository-functions

FreeSubmissionRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/FreeSubmissionRepository.kt

functions

  • getExerciseSubmissionForUser return the free-text-submission of an user on an exercise with the input of the user_id and exercise_id
  • insertFreeSubmission adds a free-text-Submission with the input of the submission_id and the content

McAnswerRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/McAnswerRepository.kt

functions

  • getAnswersForQuestion returns all answers to a Questions with the input of the question_id
  • delAnswersForQuestion removes all answers to a Questions with the input of the question_id
  • getAnswersBySubmission returns all answers to a Submission with the input of the submission_id
  • addAnswersBySubmission adds an answer to a Submission with the input of submission_id, answer_id and boolean marked
  • editAnswersBySubmission edits an answer of a Submission with the input of submission_id, answer_id and boolean marked
  • deleteAnswersBySubmission deletes all answers to a Submission with the input of the submission_id

McQuestionRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/McQuestionRepository.kt

functions

  • getMcForExercise returns all Questions to an exercise with the input of the exercise_id
  • delQuestionsForExercise removes all Questions to an exercise with the input of the exercise_id

TagRepository

path

src/main/kotlin/com/example/atlasbackend/repository/TagRepository.kt

functions

  • getExerciseTags returns all tags of an exercise, with the input of the id of the exercise.
  • addExerciseTag adds a tag to an exercise, with the input of the id of the exercise and the tag.
  • removeExerciseTag removes a tag from a exercise, with the input of the exercise id and the tag.
  • getModuleTags returns all tags of a Module, with the input of the id of the module.
  • addModuleTag adds a tag to a Module, with the input of the id of tag and module.
  • removeModuleTag remove a tog of a Module, with the input the id of tag and module.
  • loadPage returns a page of all tags

UserRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/UserRepository.kt

functions

  • testForUser returns the list of all users with this name, with the input of a username.
  • getPassword returns the value of the user's password, with the input of a username.
  • addPassword processes the password of a user, with the input of a username and password.
  • loadPage returns a page of all users, with the input of a page-size and an offset.

Iconrepository

Path

src/main/kotlin/com/example/atlasbackend/repository/IconRepository.kt

functions

The Iconrepository has no functions apart from the inherited CrudRepository functions

NotificationRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/NotificationRepository.kt

functions

  • getNotificationsByUser returns all notifications for a user with the input of the user_id
  • getUserIdByNotification returns the user_id for a notification with the input of the notification_id
  • getNotificationsByModule returns all notifications of a module with the input of the module_id
  • deleteByIdByUser removes a notification of a user with the input of the notification_id and user_id
  • deleteByUser removes all notifications of a user with the input of the user_id
  • addNotificationByUser adds a notification for a user with the input of the user_id an d notification_id
  • getReadStatus return the status if a notification is read with the input of the user_id and notification_id
  • countNotificationRelations returns the count of notifications of a user with the input of the notification_id
  • updateReadStatus updates the status if the notification is read with the input of the notification_id, user_id and a boolean status

NotificationTypeRepository

Path

src/main/kotlin/com/example/atlasbackend/repository/NotificationTypeRepository.kt

functions

The NotificationTypeRepository has no functions apart from the inherited CrudRepository functions