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

Commit

Permalink
docs(reminder): add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaBrighi committed Jun 20, 2023
1 parent 919b5b9 commit 44c3168
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ import com.intelligentbackpack.reminderdomain.entitites.ReminderForLessonInterva
import com.intelligentbackpack.reminderdata.db.entities.Lesson as DBLesson
import com.intelligentbackpack.reminderdata.db.entities.Reminder as DBReminder

/**
* Adapter for converting [DBReminder] to [ReminderForLesson] and vice versa or [ReminderForLesson] to [DBReminder] and vice versa.
*/
object ReminderAdapter {

/**
* Converts a [String] to a [DBReminder].
*
* @param lesson The [DBLesson] to get the [DBLesson.fromDate] and [DBLesson.toDate] from.
*/
fun String.fromRemoteToDB(lesson: DBLesson): DBReminder {
return DBReminder(
id = 0,
Expand All @@ -20,6 +28,13 @@ object ReminderAdapter {
)
}

/**
* Converts a [DBReminder] to a [ReminderForLesson].
* if the [DBReminder] is a [DBReminder] with the same [DBReminder.fromDate] and [DBReminder.toDate] then it will be converted to a [ReminderForLessonDate].
* if the [DBReminder] is a [DBReminder] with different [DBReminder.fromDate] and [DBReminder.toDate] then it will be converted to a [ReminderForLessonIntervalPeriod].
*
* @param lessons The list of lessons to get the lesson from the lesson id.
*/
fun DBReminder.fromDBToDomain(lessons: List<DBLesson>, subjects: List<Subject>): ReminderForLesson {
if (fromDate == toDate) {
return ReminderForLessonDate.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import com.intelligentbackpack.reminderdomain.entitites.Reminder as DomainReminder

/**
* Reminder domain repository implementation
*
* @param remoteDataSource the remote data source
* @param localDataSource the local data source
*/
class ReminderDomainRepositoryImpl(
private val remoteDataSource: ReminderRemoteDataSource,
private val localDataSource: ReminderLocalDataSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ package com.intelligentbackpack.schooldata.adapter
import calendar.communication.Subject as RemoteSubject
import com.intelligentbackpack.schooldata.db.entities.Subject as DBSubject

/**
* Adapter for the subject entity.
*/
object SubjectAdapter {

/**
* Converts a subject from the remote to the database.
*
* @return the subject for the database.
*/
fun RemoteSubject.fromRemoteToDB(): DBSubject {
return DBSubject(
subjectId = id.toInt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,72 @@ import com.intelligentbackpack.schooldata.db.entities.Teach
import java.time.LocalDate
import java.time.LocalTime

/**
* Interface for the local data source.
*/
interface SchoolLocalDataSource {

/**
* Gets all the subjects.
*
* @return the subjects.
*/
suspend fun getSubjects(): List<Subject>

/**
* Inserts a subject.
*
* @param subject the subject to add.
*/
suspend fun insertSubject(subject: Subject)

/**
* Inserts a list of subjects.
*
* @param subjects the subjects to add.
*/
suspend fun insertSubjects(subjects: List<Subject>) {
subjects.forEach { insertSubject(it) }
}

/**
* Inserts a class.
*
* @param schoolClass the class to add.
*/
suspend fun insertClass(schoolClass: SchoolClass)

/**
* Inserts a professor.
*
* @param professor the professor to add.
*/
suspend fun insertProfessor(professor: Professor)

/**
* Inserts a teaching relationship.
*
* @param teach the teach to add.
* @return the id of the inserted teach.
*/
suspend fun insertTeach(teach: Teach): Long

/**
* Inserts a lesson.
*
* @param lesson the lesson to add.
*/
suspend fun insertLesson(lesson: Lesson)

/**
* Gets the lesson for the day, time and date.
*
* @param day the day of the week of the lessons.
* @param startTime the start time of the lessons.
* @param endTime the end time of the lessons.
* @param fromDate the start date of the lessons.
* @param toDate the end date of the lessons.
*/
suspend fun getLesson(
day: Int,
startTime: LocalTime,
Expand All @@ -34,25 +82,93 @@ interface SchoolLocalDataSource {
toDate: LocalDate,
): Lesson?

/**
* Gets the lessons.
*
* @return the lessons.
*/
suspend fun getLessons(): List<Lesson>

/**
* Deletes all the data.
*/
suspend fun deleteData()

/**
* Saves the school and the city.
*
* @param school the school to save.
* @param city the city to save.
*/
suspend fun saveSchool(school: String, city: String)

/**
* Returns the school.
*
* @return the school.
*/
suspend fun getSchool(): String

/**
* Returns the city of the school.
*
* @return the city.
*/
suspend fun getCity(): String

/**
* Checks if the user is a student.
*
* @return true if the user is a student, false otherwise.
*/
suspend fun isStudent(): Boolean

/**
* Saves the student class.
*
* @param name the name of the class.
*/
suspend fun saveClass(name: String)

/**
* Gets the student class.
*
* @return the name of the class.
*/
suspend fun getUserClass(): String

/**
* Saves the school year.
*
* @param year the year to save.
*/
suspend fun saveYear(year: String)

/**
* Gets the school year.
*
* @return the year.
*/
suspend fun getYear(): String

/**
* Gets all the classes from the database.
*
* @return the classes.
*/
suspend fun getClasses(): List<SchoolClass>

/**
* Gets all the professors from the database.
*
* @return the professors.
*/
suspend fun getProfessors(): List<Professor>

/**
* Gets all the teaches from the database.
*
* @return the teaches.
*/
suspend fun getTeaches(): List<Teach>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,66 @@ import calendar.communication.Lesson
import calendar.communication.Subject
import calendar.communication.UserInformations

/**
* Interface for the remote data source.
*/
interface SchoolRemoteDataSource {

/**
* Downloads the year.
*
* @return the year.
*/
suspend fun downloadYear(): String

/**
* Downloads the subjects.
*
* @return the subjects.
*/
suspend fun downloadSubjects(): List<Subject>

/**
* Downloads the lessons for a student.
*
* @param email the email of the student.
* @param year the year.
* @return the lessons.
*/
suspend fun downloadLessonsForStudent(email: String, year: String): List<Lesson>

/**
* Downloads the lessons for a professor.
*
* @param email the email of the professor.
* @param year the year.
* @return the lessons.
*/
suspend fun downloadLessonsForProfessor(email: String, year: String): List<Lesson>

/**
* Downloads the student information.
*
* @param email the email of the student.
* @param year the year.
* @return the student information.
*/
suspend fun downloadStudent(email: String, year: String): UserInformations

/**
* Downloads the professor information.
*
* @param email the email of the professor.
* @param year the year.
* @return the professor information.
*/
suspend fun downloadProfessor(email: String, year: String): UserInformations

/**
* Downloads the class of a lesson.
*
* @param lesson the lesson.
* @return the class.
*/
suspend fun getClass(lesson: Lesson): String
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,63 @@
package com.intelligentbackpack.schooldata.storage

/**
* Interface for the storage.
*/
interface SchoolStorage {
/**
* Saves the school and the city.
*
* @param school the school.
* @param city the city.
*/
fun saveSchool(school: String, city: String)

/**
* Returns the school.
*
* @return the school.
*/
fun getSchool(): String

/**
* Returns the city of the school.
*
* @return the city.
*/
fun getCity(): String

/**
* Checks if the user is a student.
*
* @return true if the user is a student, false otherwise.
*/
fun isStudent(): Boolean

/**
* Saves the student class.
*
* @param name the name of the class.
*/
fun saveClass(name: String)

/**
* Gets the student class.
*
* @return the name of the class.
*/
fun getClass(): String

/**
* Saves the school year.
*
* @param year the year to save.
*/
fun saveYear(year: String)

/**
* Gets the school year.
*
* @return the year.
*/
fun getYear(): String
}

0 comments on commit 44c3168

Please sign in to comment.