Jean-Francois Leveque

Élimination des multiples de l'ajout dans la liste des utilisateurs.

...@@ -62,8 +62,12 @@ public class ProcessingRunner implements ApplicationRunner { ...@@ -62,8 +62,12 @@ public class ProcessingRunner implements ApplicationRunner {
62 try { 62 try {
63 in = new FileReader(dataDir+sampleFilename); 63 in = new FileReader(dataDir+sampleFilename);
64 Iterable<CSVRecord> records = CSVFormat.TDF.withFirstRecordAsHeader().parse(in); 64 Iterable<CSVRecord> records = CSVFormat.TDF.withFirstRecordAsHeader().parse(in);
65 + Long tmpLong;
65 for (CSVRecord record : records) { 66 for (CSVRecord record : records) {
66 - userIds.add(Long.parseLong(record.get("userId"))); 67 + tmpLong = Long.parseLong(record.get("userId"));
68 + if (! userIds.contains(tmpLong)) {
69 + userIds.add(tmpLong);
70 + }
67 } 71 }
68 } catch (FileNotFoundException e) { 72 } catch (FileNotFoundException e) {
69 throw new ProcessingException("sample file not found " + dataDir + sampleFilename, e); 73 throw new ProcessingException("sample file not found " + dataDir + sampleFilename, e);
...@@ -71,6 +75,7 @@ public class ProcessingRunner implements ApplicationRunner { ...@@ -71,6 +75,7 @@ public class ProcessingRunner implements ApplicationRunner {
71 throw new ProcessingException("Can't read user ids from sample file " + dataDir + sampleFilename, e); 75 throw new ProcessingException("Can't read user ids from sample file " + dataDir + sampleFilename, e);
72 } 76 }
73 77
78 + logger.trace("Nombre d'utilisateurs : {}", userIds.size());
74 return userIds; 79 return userIds;
75 } 80 }
76 81
......