From 5983ed395833cc6a782ed971978222a041a476e6 Mon Sep 17 00:00:00 2001 From: Chloe Renaud Date: Thu, 8 Jan 2026 17:46:31 +0100 Subject: [PATCH 1/3] feat: add source variable references to handle pairwise magic variables --- pom.xml | 2 +- src/main/resources/xsd/Questionnaire.xsd | 7 ++++++ .../resources/xsd/multimode/Multimode.xsd | 1 - src/main/resources/xsd/pairwise/Pairwise.xsd | 25 +++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/xsd/pairwise/Pairwise.xsd diff --git a/pom.xml b/pom.xml index 6b56491..66104a2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ fr.insee.pogues pogues-model - 1.13.0 + 1.14.0-SNAPSHOT jar Pogues Model diff --git a/src/main/resources/xsd/Questionnaire.xsd b/src/main/resources/xsd/Questionnaire.xsd index b3a4632..565411d 100644 --- a/src/main/resources/xsd/Questionnaire.xsd +++ b/src/main/resources/xsd/Questionnaire.xsd @@ -6,6 +6,7 @@ + @@ -220,6 +221,12 @@ + + + References of variables used by pairwise + questions to define the indivisuals. + + codeFilters is list of CodeFilter, indicate in this question, diff --git a/src/main/resources/xsd/multimode/Multimode.xsd b/src/main/resources/xsd/multimode/Multimode.xsd index 5467145..696f309 100644 --- a/src/main/resources/xsd/multimode/Multimode.xsd +++ b/src/main/resources/xsd/multimode/Multimode.xsd @@ -23,7 +23,6 @@ - diff --git a/src/main/resources/xsd/pairwise/Pairwise.xsd b/src/main/resources/xsd/pairwise/Pairwise.xsd new file mode 100644 index 0000000..353b931 --- /dev/null +++ b/src/main/resources/xsd/pairwise/Pairwise.xsd @@ -0,0 +1,25 @@ + + + + + + + + A pairwise question is defined from source variables + which allow to know the individuals we are specifying the links of. + + The name source variable allow to ask the question + "what is he nature of the relationship between A and B?". + + The gender and age source variable allow to compute + additional information about the indivisuals (to display a recap or to + generate complex variables to create filters from). + + + + + + + + + \ No newline at end of file From cb7a735103a67ebfe8623824bcac362f20648b31 Mon Sep 17 00:00:00 2001 From: Chloe Renaud Date: Thu, 15 Jan 2026 10:24:35 +0100 Subject: [PATCH 2/3] test: add test --- .../pogues/test/JSONDeserializerTest.java | 31 +++++++++++++++ .../insee/pogues/test/JSONSerializerTest.java | 38 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/src/test/java/fr/insee/pogues/test/JSONDeserializerTest.java b/src/test/java/fr/insee/pogues/test/JSONDeserializerTest.java index a723c1d..1d6c851 100644 --- a/src/test/java/fr/insee/pogues/test/JSONDeserializerTest.java +++ b/src/test/java/fr/insee/pogues/test/JSONDeserializerTest.java @@ -377,4 +377,35 @@ void testExternalVariableIsDeletedOnReset() throws JAXBException { assertEquals("NUMERO_MENAGE", externalVariableType.getName()); assertTrue(externalVariableType.isDeletedOnReset()); } + + @Test + void testPairwiseSourceVariableReferences() throws JAXBException { + // Given the JSON of a question with sourceVariableReferences + String json = """ + { + "Child": [ + { + "type": "QuestionType", + "sourceVariableReferences": { + "name": "var-name-id", + "gender": "var-gender-id", + "age": "var-age-id" + } + } + ] + } + """; + + // When it is deserialized + JSONDeserializer deserializer = new JSONDeserializer(); + Questionnaire questionnaire = deserializer.deserializeString(json); + + // Then the sourceVariableReferences are correctly deserialized + QuestionType pairwiseQuestion = (QuestionType) questionnaire.getChild().getFirst(); + + assertNotNull(pairwiseQuestion); + assertEquals("var-name-id", pairwiseQuestion.getSourceVariableReferences().getName()); + assertEquals("var-gender-id", pairwiseQuestion.getSourceVariableReferences().getGender()); + assertEquals("var-age-id", pairwiseQuestion.getSourceVariableReferences().getAge()); + } } diff --git a/src/test/java/fr/insee/pogues/test/JSONSerializerTest.java b/src/test/java/fr/insee/pogues/test/JSONSerializerTest.java index c4c969b..bc49cb4 100644 --- a/src/test/java/fr/insee/pogues/test/JSONSerializerTest.java +++ b/src/test/java/fr/insee/pogues/test/JSONSerializerTest.java @@ -4,6 +4,7 @@ import fr.insee.pogues.mock.*; import fr.insee.pogues.model.*; import org.apache.commons.io.FileUtils; +import org.apache.logging.log4j.core.util.Source; import org.json.JSONException; import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -638,4 +639,41 @@ void serializeExternalVariableIsDeletedOnReset() throws JAXBException, Unsupport JSONAssert.assertEquals(expectedJson, result, JSONCompareMode.STRICT); } + + @Test + void serializePairwiseSourceVariableReferences() throws JAXBException, UnsupportedEncodingException, JSONException { + // Given a questionnaire with a question with sourceVariableReferences + Questionnaire questionnaire = new Questionnaire(); + + QuestionType pairwiseQuestion = new QuestionType(); + SourceVariableReferences sourceVariableReferences = new SourceVariableReferences(); + sourceVariableReferences.setName("var-name-id"); + sourceVariableReferences.setGender("var-gender-id"); + sourceVariableReferences.setAge("var-age-id"); + pairwiseQuestion.setSourceVariableReferences(sourceVariableReferences); + + questionnaire.getChild().add(pairwiseQuestion); + + // When it is serialized + JSONSerializer serializer = new JSONSerializer(true); + String result = serializer.serialize(questionnaire); + + String expectedJson = """ + { + "Child": [ + { + "type": "QuestionType", + "sourceVariableReferences": { + "name": "var-name-id", + "gender": "var-gender-id", + "age": "var-age-id" + } + } + ] + } + """; + + // Then the sourceVariableReferences are correctly serialized + JSONAssert.assertEquals(expectedJson, result, JSONCompareMode.STRICT); + } } From 65122a2766f5b39324bc8faa42f46e97769b8333 Mon Sep 17 00:00:00 2001 From: nsenave Date: Thu, 15 Jan 2026 14:08:47 +0100 Subject: [PATCH 3/3] chore: release version [skip ci] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f58030d..e61d183 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ fr.insee.pogues pogues-model - 1.14.0-SNAPSHOT + 1.14.0 jar Pogues Model