@@ -65,7 +65,7 @@ public List<SurveyUnitModel> findLatestByIdAndByIdQuestionnaire(String idUE, Str
6565 //We had all the variables of the oldest update
6666 latestUpdatesbyVariables .add (suByMode .getFirst ());
6767 //We keep the name of already added variables to skip them in older updates
68- List <IdTuple > addedVariables = new ArrayList <>();
68+ List <IdLoopTuple > addedVariables = new ArrayList <>();
6969 SurveyUnitModel latestUpdate = suByMode .getFirst ();
7070
7171 if (latestUpdate .getCollectedVariables () == null ){
@@ -74,25 +74,25 @@ public List<SurveyUnitModel> findLatestByIdAndByIdQuestionnaire(String idUE, Str
7474 if (latestUpdate .getExternalVariables () == null ){
7575 latestUpdate .setExternalVariables (new ArrayList <>());
7676 }
77- latestUpdate .getCollectedVariables ().forEach (colVar -> addedVariables .add (new IdTuple (colVar .getIdVar (), colVar .getIdLoop ())));
78- latestUpdate .getExternalVariables ().forEach (extVar -> addedVariables .add (new IdTuple (extVar .getIdVar (), "" )));
77+ latestUpdate .getCollectedVariables ().forEach (colVar -> addedVariables .add (new IdLoopTuple (colVar .getIdVar (), colVar .getIdLoop ())));
78+ latestUpdate .getExternalVariables ().forEach (extVar -> addedVariables .add (new IdLoopTuple (extVar .getIdVar (), "" )));
7979
8080 suByMode .forEach (surveyUnitModel -> {
8181 List <CollectedVariable > variablesToKeep = new ArrayList <>();
8282 List <Variable > externalToKeep = new ArrayList <>();
8383 // We iterate over the variables of the update and add them to the list if they are not already added
8484 surveyUnitModel .getCollectedVariables ().stream ()
85- .filter (colVar -> !addedVariables .contains (new IdTuple (colVar .getIdVar (), colVar .getIdLoop ())))
85+ .filter (colVar -> !addedVariables .contains (new IdLoopTuple (colVar .getIdVar (), colVar .getIdLoop ())))
8686 .forEach (colVar -> {
8787 variablesToKeep .add (colVar );
88- addedVariables .add (new IdTuple (colVar .getIdVar (), colVar .getIdLoop ()));
88+ addedVariables .add (new IdLoopTuple (colVar .getIdVar (), colVar .getIdLoop ()));
8989 });
9090 if (surveyUnitModel .getExternalVariables () != null ){
9191 surveyUnitModel .getExternalVariables ().stream ()
92- .filter (extVar -> !addedVariables .contains (new IdTuple (extVar .getIdVar (), "" )))
92+ .filter (extVar -> !addedVariables .contains (new IdLoopTuple (extVar .getIdVar (), "" )))
9393 .forEach (extVar -> {
9494 externalToKeep .add (extVar );
95- addedVariables .add (new IdTuple (extVar .getIdVar (), "" ));
95+ addedVariables .add (new IdLoopTuple (extVar .getIdVar (), "" ));
9696 });
9797 }
9898
@@ -116,7 +116,7 @@ public SurveyUnitDto findLatestValuesByStateByIdAndByIdQuestionnaire(String idUE
116116 .build ();
117117
118118 //Extract variables
119- Map <IdTuple , VariableDto > collectedVariableMap = new HashMap <>();
119+ Map <IdLoopTuple , VariableDto > collectedVariableMap = new HashMap <>();
120120 Map <String , VariableDto > externalVariableMap = new HashMap <>();
121121 List <SurveyUnitModel > surveyUnitModels = surveyUnitPersistencePort .findByIds (idUE , idQuest );
122122 List <Mode > modes = getDistinctsModes (surveyUnitModels );
@@ -229,15 +229,15 @@ private static List<Mode> getDistinctsModes(List<SurveyUnitModel> surveyUnitMode
229229 * @param externalVariableMap External variable DTO map to populate
230230 */
231231 private void extractVariables (SurveyUnitModel surveyUnitModel ,
232- Map <IdTuple , VariableDto > collectedVariableMap ,
232+ Map <IdLoopTuple , VariableDto > collectedVariableMap ,
233233 Map <String , VariableDto > externalVariableMap ) {
234234
235235 if (surveyUnitModel .getCollectedVariables () == null ){
236236 surveyUnitModel .setCollectedVariables (new ArrayList <>());
237237 }
238238 for (CollectedVariable collectedVariable : surveyUnitModel .getCollectedVariables ()) {
239- IdTuple idTuple = new IdTuple (collectedVariable .getIdVar (), collectedVariable .getIdLoop ());
240- VariableDto variableDto = collectedVariableMap .get (idTuple );
239+ IdLoopTuple idLoopTuple = new IdLoopTuple (collectedVariable .getIdVar (), collectedVariable .getIdLoop ());
240+ VariableDto variableDto = collectedVariableMap .get (idLoopTuple );
241241
242242 //Create variable into map if not exists
243243 if (variableDto == null ) {
@@ -246,7 +246,7 @@ private void extractVariables(SurveyUnitModel surveyUnitModel,
246246 .idLoop (collectedVariable .getIdLoop ())
247247 .variableStateDtoList (new ArrayList <>())
248248 .build ();
249- collectedVariableMap .put (idTuple , variableDto );
249+ collectedVariableMap .put (idLoopTuple , variableDto );
250250 }
251251 //Extract variable state
252252 if (!collectedVariable .getValues ().isEmpty () && isMostRecentForSameState (surveyUnitModel , variableDto )) {
0 commit comments