@@ -23,34 +23,34 @@ public class LunaticXmlAdapter {
2323 * Convert a Lunatic XML survey unit into a genesis survey unit model
2424 * @param su Lunatic XML survey unit to convert
2525 * @param variablesMap variable definitions (used for loops)
26- * @param idCampaign survey id
26+ * @param campaignId survey id
2727 * @return Genesis SurveyUnitModels for each data state
2828 */
29- public static List <SurveyUnitModel > convert (LunaticXmlSurveyUnit su , VariablesMap variablesMap , String idCampaign , Mode mode ){
29+ public static List <SurveyUnitModel > convert (LunaticXmlSurveyUnit su , VariablesMap variablesMap , String campaignId , Mode mode ){
3030 //Get COLLECTED Data and external variables
3131 List <SurveyUnitModel > surveyUnitModelList = new ArrayList <>();
32- SurveyUnitModel surveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , idCampaign , DataState .COLLECTED , mode );
32+ SurveyUnitModel surveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , campaignId , DataState .COLLECTED , mode );
3333 getExternalDataFromSurveyUnit (su , surveyUnitModel , variablesMap );
3434
3535 surveyUnitModelList .add (surveyUnitModel );
3636
3737 //Get data from other states
38- SurveyUnitModel editedSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , idCampaign , DataState .EDITED ,mode );
38+ SurveyUnitModel editedSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , campaignId , DataState .EDITED ,mode );
3939 if (editedSurveyUnitModel != null ){
4040 surveyUnitModelList .add (editedSurveyUnitModel );
4141 }
4242
43- SurveyUnitModel inputedSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , idCampaign , DataState .INPUTED ,mode );
43+ SurveyUnitModel inputedSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , campaignId , DataState .INPUTED ,mode );
4444 if (inputedSurveyUnitModel != null ){
4545 surveyUnitModelList .add (inputedSurveyUnitModel );
4646 }
4747
48- SurveyUnitModel forcedSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , idCampaign , DataState .FORCED ,mode );
48+ SurveyUnitModel forcedSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , campaignId , DataState .FORCED ,mode );
4949 if (forcedSurveyUnitModel != null ){
5050 surveyUnitModelList .add (forcedSurveyUnitModel );
5151 }
5252
53- SurveyUnitModel previousSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , idCampaign , DataState .PREVIOUS ,mode );
53+ SurveyUnitModel previousSurveyUnitModel = getStateDataFromSurveyUnit (su , variablesMap , campaignId , DataState .PREVIOUS ,mode );
5454 if (previousSurveyUnitModel != null ){
5555 surveyUnitModelList .add (previousSurveyUnitModel );
5656 }
@@ -63,15 +63,15 @@ public static List<SurveyUnitModel> convert(LunaticXmlSurveyUnit su, VariablesMa
6363 * Collects data from XML survey unit depending on the data state
6464 * @param su source XML Survey Unit
6565 * @param variablesMap variable definitions (used for loops)
66- * @param idCampaign survey id
66+ * @param campaignId survey id
6767 * @param dataState state of the SurveyUnitModel to generate
6868 * @return SurveyUnitModel with a specific state
6969 */
70- private static SurveyUnitModel getStateDataFromSurveyUnit (LunaticXmlSurveyUnit su , VariablesMap variablesMap , String idCampaign , DataState dataState , Mode mode ) {
70+ private static SurveyUnitModel getStateDataFromSurveyUnit (LunaticXmlSurveyUnit su , VariablesMap variablesMap , String campaignId , DataState dataState , Mode mode ) {
7171 SurveyUnitModel surveyUnitModel = SurveyUnitModel .builder ()
72- .idQuest (su .getQuestionnaireModelId ())
73- .idCampaign ( idCampaign )
74- .idUE (su .getId ())
72+ .questionnaireId (su .getQuestionnaireModelId ())
73+ .campaignId ( campaignId )
74+ .interrogationId (su .getId ())
7575 .state (dataState )
7676 .mode (mode )
7777 .recordDate (LocalDateTime .now ())
@@ -119,14 +119,13 @@ private static SurveyUnitModel getCollectedDataFromSurveyUnit(LunaticXmlSurveyUn
119119 continue ; //Go to next data
120120 }
121121 for (int i = 1 ; i <= valueTypeList .size (); i ++) {
122- List <String > variableValues = new ArrayList <>();
123122 if (valueTypeList .get (i -1 ).getValue ()!=null ) {
124- variableValues .add (valueTypeList .get (i -1 ).getValue ());
125123 variableModels .add (VariableModel .builder ()
126- .idVar (lunaticXmlCollectedData .getVariableName ())
127- .values (variableValues )
128- .idLoop (LoopIdentifier .getLoopIdentifier (lunaticXmlCollectedData .getVariableName (), variablesMap , i ))
129- .idParent (LoopIdentifier .getRelatedVariableName (lunaticXmlCollectedData .getVariableName (), variablesMap ))
124+ .varId (lunaticXmlCollectedData .getVariableName ())
125+ .value (valueTypeList .get (i -1 ).getValue ())
126+ .scope (LoopIdentifier .getLoopIdentifier (lunaticXmlCollectedData .getVariableName (), variablesMap ))
127+ .parentId (LoopIdentifier .getRelatedVariableName (lunaticXmlCollectedData .getVariableName (), variablesMap ))
128+ .iteration (i )
130129 .build ());
131130 dataCount ++;
132131 }
@@ -157,14 +156,13 @@ private static void getExternalDataFromSurveyUnit(LunaticXmlSurveyUnit su, Surve
157156 continue ; //Go to next data
158157 }
159158 for (int i = 1 ; i <= valueTypeList .size (); i ++) {
160- List <String > variableValues = new ArrayList <>();
161159 if (valueTypeList .get (i -1 ).getValue ()!=null ) {
162- variableValues .add (valueTypeList .get (i -1 ).getValue ());
163160 variableModels .add (VariableModel .builder ()
164- .idVar (lunaticXmlExternalData .getVariableName ())
165- .values (variableValues )
166- .idLoop (LoopIdentifier .getLoopIdentifier (lunaticXmlExternalData .getVariableName (), variablesMap , i ))
167- .idParent (LoopIdentifier .getRelatedVariableName (lunaticXmlExternalData .getVariableName (), variablesMap ))
161+ .varId (lunaticXmlExternalData .getVariableName ())
162+ .value (valueTypeList .get (i -1 ).getValue ())
163+ .scope (LoopIdentifier .getLoopIdentifier (lunaticXmlExternalData .getVariableName (), variablesMap ))
164+ .iteration (i )
165+ .parentId (LoopIdentifier .getRelatedVariableName (lunaticXmlExternalData .getVariableName (), variablesMap ))
168166 .build ());
169167 }
170168 }
0 commit comments