Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(school): add query to delete data
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaBrighi committed Jun 20, 2023
1 parent 2c633c8 commit d05abf7
Showing 1 changed file with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,101 @@ import java.time.LocalDate
import java.time.LocalTime

/**
* Desktop DAO to access database
* School DAO to access database
*/
@Dao
internal interface SchoolDAO {

/**
* Insert a subject
*
* @param subject the subject to insert
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertSubject(subject: Subject)

/**
* Insert a lesson
*
* @param lesson the lesson to insert
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertLesson(lesson: Lesson)

/**
* Insert a professor
*
* @param professor the professor to insert
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertProfessor(professor: Professor)

/**
* Insert a class
*
* @param schoolClass the class to insert
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertClass(schoolClass: SchoolClass)

/**
* Insert a teach
*
* @param teach the teach to insert
* @return the id of the inserted teach
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertTeach(teach: Teach): Long

/**
* Delete all lessons
*/
@Query("DELETE FROM Lessons")
fun deleteLessons()

/**
* Delete all subjects
*/
@Query("DELETE FROM Subjects")
fun deleteSubjects()

/**
* Delete all professors
*/
@Query("DELETE FROM Professors")
fun deleteProfessors()

/**
* Delete all classes
*/
@Query("DELETE FROM Classes")
fun deleteClasses()

/**
* Delete all teaches
*/
@Query("DELETE FROM Teaches")
fun deleteTeaches()

/**
* Get all subjects
*
* @return all subjects
*/
@Query("SELECT * FROM Subjects")
fun getSubjects(): List<Subject>

/**
* Get a lessons by day, start time, end time, from date and to date
*
* @param day the day of the lesson
* @param startTime the start time of the lesson
* @param endTime the end time of the lesson
* @param fromDate the from date of the lesson
* @param toDate the to date of the lesson
* @return the lesson if found, null otherwise
*
*/
@Query(
"SELECT * " +
"FROM Lessons " +
Expand All @@ -56,15 +119,35 @@ internal interface SchoolDAO {
)
fun getLesson(day: Int, startTime: LocalTime, endTime: LocalTime, fromDate: LocalDate, toDate: LocalDate): Lesson?

/**
* Get all lessons
*
* @return all lessons
*/
@Query("SELECT * FROM Lessons")
fun getLessons(): List<Lesson>

/**
* Get all classes
*
* @return all classes
*/
@Query("SELECT * FROM Classes")
fun getClasses(): List<SchoolClass>

/**
* Get all professors
*
* @return all professors
*/
@Query("SELECT * FROM Professors")
fun getProfessors(): List<Professor>

/**
* Get all teaches
*
* @return all teaches
*/
@Query("SELECT * FROM Teaches")
fun getTeaches(): List<Teach>
}

0 comments on commit d05abf7

Please sign in to comment.