Skip to content

Commit

Permalink
fix(PnX-SI/gn_mobile_occtax#223): distinguish nomenclature values fro…
Browse files Browse the repository at this point in the history
…m given mnemonic and taxonomy kingdom and group
  • Loading branch information
sgrimault committed May 16, 2023
1 parent 801df11 commit 3b8a0bc
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 15 deletions.
2 changes: 1 addition & 1 deletion commons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'org.jetbrains.kotlin.android'
}

version = "1.2.5"
version = "1.2.6"

android {
namespace 'fr.geonature.commons'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ abstract class NomenclatureDao : BaseDao<Nomenclature>() {
* @return a list of [Nomenclature] matching given criteria
*/
@Query(
"""SELECT n.*
"""SELECT DISTINCT n.*
FROM ${Nomenclature.TABLE_NAME} n
JOIN ${NomenclatureType.TABLE_NAME} nt ON nt.${NomenclatureType.COLUMN_ID} = n.${Nomenclature.COLUMN_TYPE_ID}
AND nt.${NomenclatureType.COLUMN_MNEMONIC} = :mnemonic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class NomenclatureDaoTest {
assertEquals(expectedNomenclatureTaxonomy
.filter { it.taxonomy == Taxonomy(kingdom = Taxonomy.ANY) }
.mapNotNull { expectedNomenclatures.find { nomenclature -> nomenclature.id == it.nomenclatureId } }
.distinctBy { it.id }
.sortedBy { it.defaultLabel },
nomenclaturesForStatutBioAndNoTaxonomy
)
Expand All @@ -145,6 +146,7 @@ class NomenclatureDaoTest {
assertEquals(expectedNomenclatureTaxonomy
.filter { it.taxonomy == Taxonomy(kingdom = Taxonomy.ANY) }
.mapNotNull { expectedNomenclatures.find { nomenclature -> nomenclature.id == it.nomenclatureId } }
.distinctBy { it.id }
.sortedBy { it.defaultLabel },
nomenclaturesForStatutBioAndAnyKingdomTaxonomy
)
Expand All @@ -168,6 +170,7 @@ class NomenclatureDaoTest {
assertEquals(expectedNomenclatureTaxonomy
.filter { it.taxonomy == Taxonomy(kingdom = Taxonomy.ANY) }
.mapNotNull { expectedNomenclatures.find { nomenclature -> nomenclature.id == it.nomenclatureId } }
.distinctBy { it.id }
.sortedBy { it.defaultLabel },
nomenclaturesForStatutBioAndAnyTaxonomy
)
Expand Down Expand Up @@ -195,6 +198,7 @@ class NomenclatureDaoTest {
).contains(it.taxonomy)
}
.mapNotNull { expectedNomenclatures.find { nomenclature -> nomenclature.id == it.nomenclatureId } }
.distinctBy { it.id }
.sortedBy { it.defaultLabel },
nomenclaturesForStatutBioAndAnyTaxonomy
)
Expand Down Expand Up @@ -227,6 +231,7 @@ class NomenclatureDaoTest {
).contains(it.taxonomy)
}
.mapNotNull { expectedNomenclatures.find { nomenclature -> nomenclature.id == it.nomenclatureId } }
.distinctBy { it.id }
.sortedBy { it.defaultLabel },
nomenclaturesForStatutBioAndAnyTaxonomy
)
Expand Down Expand Up @@ -289,32 +294,60 @@ class NomenclatureDaoTest {
val expectedNomenclatures = listOf(
Nomenclature(
id = 29,
code = "0",
hierarchy = "013.000",
defaultLabel = "Inconnu",
typeId = 13
),
Nomenclature(
id = 30,
code = "1",
hierarchy = "013.001",
defaultLabel = "Non renseigné",
typeId = 13
),
Nomenclature(
id = 31,
code = "2",
hierarchy = "013.002",
defaultLabel = "Non déterminé",
typeId = 13
),
Nomenclature(
id = 32,
code = "3",
hierarchy = "013.003",
defaultLabel = "Reproduction",
typeId = 13
),
Nomenclature(
id = 32,
id = 33,
code = "4",
hierarchy = "013.004",
defaultLabel = "Hibernation",
typeId = 13
),
Nomenclature(
id = 33,
id = 34,
code = "5",
hierarchy = "013.005",
defaultLabel = "Estivation",
typeId = 13
),
Nomenclature(
id = 35,
code = "9",
hierarchy = "013.009",
defaultLabel = "Pas de reproduction",
typeId = 13
),
Nomenclature(
id = 36,
code = "13",
hierarchy = "013.013",
defaultLabel = "Végétatif",
typeId = 13
),
Nomenclature(
id = 157,
code = "1",
Expand Down Expand Up @@ -363,66 +396,90 @@ class NomenclatureDaoTest {
nomenclatureId = 29,
taxonomy = Taxonomy(kingdom = Taxonomy.ANY)
),
NomenclatureTaxonomy(
nomenclatureId = 30,
taxonomy = Taxonomy(kingdom = Taxonomy.ANY)
),
NomenclatureTaxonomy(
nomenclatureId = 31,
taxonomy = Taxonomy(kingdom = Taxonomy.ANY)
),
NomenclatureTaxonomy(
nomenclatureId = 32,
taxonomy = Taxonomy(kingdom = "Animalia")
),
NomenclatureTaxonomy(
nomenclatureId = 31,
nomenclatureId = 32,
taxonomy = Taxonomy(kingdom = "Fungi")
),
NomenclatureTaxonomy(
nomenclatureId = 31,
nomenclatureId = 32,
taxonomy = Taxonomy(kingdom = "Plantae")
),
NomenclatureTaxonomy(
nomenclatureId = 32,
nomenclatureId = 33,
taxonomy = Taxonomy(
kingdom = "Animalia",
group = "Amphibiens"
)
),
NomenclatureTaxonomy(
nomenclatureId = 32,
nomenclatureId = 33,
taxonomy = Taxonomy(
kingdom = "Animalia",
group = "Mammifères"
)
),
NomenclatureTaxonomy(
nomenclatureId = 32,
nomenclatureId = 33,
taxonomy = Taxonomy(
kingdom = "Animalia",
group = "Oiseaux"
)
),
NomenclatureTaxonomy(
nomenclatureId = 32,
nomenclatureId = 33,
taxonomy = Taxonomy(
kingdom = "Animalia",
group = "Reptiles"
)
),
NomenclatureTaxonomy(
nomenclatureId = 33,
nomenclatureId = 34,
taxonomy = Taxonomy(
kingdom = "Animalia",
group = "Mammifères"
)
),
NomenclatureTaxonomy(
nomenclatureId = 33,
nomenclatureId = 34,
taxonomy = Taxonomy(
kingdom = "Animalia",
group = "Oiseaux"
)
),
NomenclatureTaxonomy(
nomenclatureId = 33,
nomenclatureId = 34,
taxonomy = Taxonomy(
kingdom = "Animalia",
group = "Reptiles"
)
),
NomenclatureTaxonomy(
nomenclatureId = 35,
taxonomy = Taxonomy(kingdom = "Animalia")
),
NomenclatureTaxonomy(
nomenclatureId = 35,
taxonomy = Taxonomy(kingdom = "Fungi")
),
NomenclatureTaxonomy(
nomenclatureId = 35,
taxonomy = Taxonomy(kingdom = "Plantae")
),
NomenclatureTaxonomy(
nomenclatureId = 36,
taxonomy = Taxonomy(kingdom = "Plantae")
)
)

Expand Down
4 changes: 2 additions & 2 deletions commons/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Mon Apr 10 11:39:21 CEST 2023
VERSION_CODE=4770
#Tue May 16 19:03:30 CEST 2023
VERSION_CODE=4775

0 comments on commit 3b8a0bc

Please sign in to comment.