-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
15 changed files
with
346 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/fr/medicapp/medicapp/database/dao/relations/InteractionsDAO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package fr.medicapp.medicapp.database.dao.relations | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import androidx.room.Transaction | ||
import fr.medicapp.medicapp.model.relations.Interactions | ||
|
||
@Dao | ||
interface InteractionsDAO { | ||
|
||
@Transaction | ||
@Query("SELECT * FROM Interactions") | ||
fun getAll(): List<Interactions> | ||
|
||
@Insert | ||
fun insert(interactions: Interactions) : Long | ||
|
||
@Insert | ||
fun insert(interactions: List<Interactions>) : List<Long> | ||
|
||
@Delete | ||
fun delete(interactions: Interactions) | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/fr/medicapp/medicapp/database/dao/relations/RelationsDAO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package fr.medicapp.medicapp.database.dao.relations | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import androidx.room.Transaction | ||
import fr.medicapp.medicapp.model.relations.RelationInfo | ||
import fr.medicapp.medicapp.model.relations.crossRef.Relations | ||
|
||
@Dao | ||
interface RelationsDAO { | ||
|
||
@Transaction | ||
@Query("SELECT * FROM RelationInfo") | ||
fun getAll() : List<Relations> | ||
|
||
@Insert | ||
fun insert(relation: RelationInfo): Long | ||
|
||
@Insert | ||
fun insert(relations: List<RelationInfo>): List<Long> | ||
|
||
@Delete | ||
fun delete(relation: RelationInfo) | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...c/main/java/fr/medicapp/medicapp/database/repositories/relations/InteractionRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fr.medicapp.medicapp.database.repositories.relations | ||
|
||
import android.content.Context | ||
import fr.medicapp.medicapp.database.repositories.Repository | ||
import fr.medicapp.medicapp.model.relations.Interactions | ||
|
||
class InteractionRepository(contexte : Context) : Repository(contexte) { | ||
fun getAll(): List<Interactions> { | ||
return db.InteractionsDAO().getAll() | ||
} | ||
|
||
fun insert(interactions: Interactions): Long { | ||
return db.InteractionsDAO().insert(interactions) | ||
} | ||
|
||
fun insert(interactions: List<Interactions>): List<Long> { | ||
return db.InteractionsDAO().insert(interactions) | ||
} | ||
|
||
fun delete(interactions : Interactions) { | ||
db.InteractionsDAO().delete(interactions) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/fr/medicapp/medicapp/database/repositories/relations/RelationRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package fr.medicapp.medicapp.database.repositories.relations | ||
|
||
import android.content.Context | ||
import androidx.room.Relation | ||
import fr.medicapp.medicapp.database.repositories.Repository | ||
import fr.medicapp.medicapp.model.relations.Interactions | ||
import fr.medicapp.medicapp.model.relations.crossRef.Relations | ||
|
||
class RelationRepository(contexte : Context) : Repository(contexte) { | ||
fun getAll(): List<Relations> { | ||
return db.RelationsDAO().getAll() | ||
} | ||
|
||
fun insert(relation: Relations): Long { | ||
val id = db.RelationsDAO().insert(relation.relationInfo) | ||
|
||
relation.interactions.forEach { | ||
it.relationInfoId = id | ||
} | ||
|
||
return id | ||
} | ||
|
||
fun insert(relations: List<Relations>): List<Long> { | ||
relations.forEach { | ||
insert(it) | ||
} | ||
return relations.map { it.relationInfo.id } | ||
} | ||
|
||
fun delete(relation : Relations) { | ||
relation.interactions.forEach { | ||
db.InteractionsDAO().delete(it) | ||
} | ||
db.RelationsDAO().delete(relation.relationInfo) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/fr/medicapp/medicapp/model/gson/RelationGSON.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package fr.medicapp.medicapp.model.gson | ||
|
||
import fr.medicapp.medicapp.model.relations.Interactions | ||
import fr.medicapp.medicapp.model.relations.RelationInfo | ||
import fr.medicapp.medicapp.model.relations.crossRef.Relations | ||
|
||
data class RelationGSON( | ||
var substance: String = "", | ||
var com: String = "", | ||
var interactions: List<Interactions> = emptyList() | ||
) { | ||
fun toRelations(): Relations { | ||
return Relations( | ||
relationInfo = RelationInfo( | ||
substance = substance, | ||
com = com | ||
), | ||
interactions = interactions | ||
) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/fr/medicapp/medicapp/model/relations/Interactions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package fr.medicapp.medicapp.model.relations | ||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity | ||
data class Interactions( | ||
@PrimaryKey(autoGenerate = true) | ||
@ColumnInfo(name = "interaction_id") | ||
val id: Long = 0L, | ||
val substance: String = "", | ||
val com1: String = "", | ||
val com2: String = "", | ||
|
||
@ColumnInfo(name = "relation_info_id") | ||
var relationInfoId: Long = 0L | ||
) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/fr/medicapp/medicapp/model/relations/RelationInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fr.medicapp.medicapp.model.relations | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity | ||
data class RelationInfo( | ||
@PrimaryKey(autoGenerate = true) | ||
@ColumnInfo(name = "relation_info_id") | ||
val id: Long = 0L, | ||
val substance: String = "", | ||
val com: String = "" | ||
) |
Oops, something went wrong.