@@ -221,70 +221,27 @@ public Optional<IndividualTimeSeriesMetaInformation> getIndividualTimeSeriesMeta
221
221
}
222
222
223
223
/**
224
- * Initialises the readers for time series with the specified column schemes. They are given back
225
- * grouped by the column scheme in order to allow for accounting the different content types.
224
+ * Receive the information for specific time series They are given back grouped by the column
225
+ * scheme in order to allow for accounting the different content types.
226
226
*
227
227
* @param columnSchemes the column schemes to initialize readers for. If no scheme is given, all
228
228
* possible readers will be initialized.
229
- * @return A mapping from column type to respective readers
230
- * @deprecated Don't use {@link TimeSeriesReadingData}, as it contains a reader, that might not be
231
- * closed
229
+ * @return A mapping from column scheme to the individual time series meta information
232
230
*/
233
- @ Deprecated
234
- public Map <ColumnScheme , Set <TimeSeriesReadingData >> initTimeSeriesReader (
235
- ColumnScheme ... columnSchemes ) {
231
+ public Map <ColumnScheme , Set <CsvIndividualTimeSeriesMetaInformation >>
232
+ getCsvIndividualTimeSeriesMetaInformation (ColumnScheme ... columnSchemes ) {
236
233
return getIndividualTimeSeriesFilePaths ()
237
234
.parallelStream ()
238
235
.map (
239
236
pathString -> {
240
237
String filePathWithoutEnding = removeFileEnding (pathString );
241
- return buildReadingData (filePathWithoutEnding , columnSchemes );
238
+ return buildCsvTimeSeriesMetaInformation (filePathWithoutEnding , columnSchemes );
242
239
})
243
240
.filter (Optional ::isPresent )
244
241
.map (Optional ::get )
245
- .collect (Collectors .groupingBy (TimeSeriesReadingData ::getColumnScheme , Collectors .toSet ()));
246
- }
247
-
248
- /**
249
- * Initialises a reader to get grip on the file that contains mapping information between
250
- * coordinate id and actual coordinate
251
- *
252
- * @return A {@link BufferedReader}
253
- * @throws FileNotFoundException If the file is not present
254
- */
255
- public BufferedReader initIdCoordinateReader () throws FileNotFoundException {
256
- String filePath = entityPersistenceNamingStrategy .getIdCoordinateEntityName ();
257
- return initReader (filePath );
258
- }
259
-
260
- /**
261
- * Returns a set of relative paths strings to time series files, with respect to the base folder
262
- * path
263
- *
264
- * @return A set of relative paths to time series files, with respect to the base folder path
265
- */
266
- private Set <String > getIndividualTimeSeriesFilePaths () {
267
- Path baseDirectoryPath =
268
- Paths .get (
269
- FilenameUtils .getFullPath (baseDirectoryName )
270
- + FilenameUtils .getName (baseDirectoryName ));
271
- try (Stream <Path > pathStream = Files .walk (baseDirectoryPath )) {
272
- return pathStream
273
- .map (baseDirectoryPath ::relativize )
274
- .filter (
275
- path -> {
276
- String withoutEnding = removeFileEnding (path .toString ());
277
- return entityPersistenceNamingStrategy
278
- .getIndividualTimeSeriesPattern ()
279
- .matcher (withoutEnding )
280
- .matches ();
281
- })
282
- .map (Path ::toString )
283
- .collect (Collectors .toSet ());
284
- } catch (IOException e ) {
285
- log .error ("Unable to determine time series files readers for time series." , e );
286
- return Collections .emptySet ();
287
- }
242
+ .collect (
243
+ Collectors .groupingBy (
244
+ CsvIndividualTimeSeriesMetaInformation ::getColumnScheme , Collectors .toSet ()));
288
245
}
289
246
290
247
/**
@@ -295,12 +252,9 @@ private Set<String> getIndividualTimeSeriesFilePaths() {
295
252
* @param filePathString String describing the path to the time series file
296
253
* @param columnSchemes the allowed column schemes. If no scheme is specified, all schemes are
297
254
* allowed.
298
- * @return An {@link Optional} to {@link TimeSeriesReadingData}
299
- * @deprecated Don't use {@link TimeSeriesReadingData}, as it contains a reader, that might not be
300
- * closed
255
+ * @return An {@link Optional} to {@link IndividualTimeSeriesMetaInformation}
301
256
*/
302
- @ Deprecated
303
- private Optional <TimeSeriesReadingData > buildReadingData (
257
+ private Optional <CsvIndividualTimeSeriesMetaInformation > buildCsvTimeSeriesMetaInformation (
304
258
String filePathString , ColumnScheme ... columnSchemes ) {
305
259
try {
306
260
FileNameMetaInformation metaInformation =
@@ -327,23 +281,60 @@ private Optional<TimeSeriesReadingData> buildReadingData(
327
281
columnSchemes );
328
282
return Optional .empty ();
329
283
}
330
-
331
- BufferedReader reader = initReader (filePathString );
332
284
return Optional .of (
333
- new TimeSeriesReadingData (
285
+ new CsvIndividualTimeSeriesMetaInformation (
334
286
individualMetaInformation .getUuid (),
335
287
individualMetaInformation .getColumnScheme (),
336
- reader ));
337
- } catch (FileNotFoundException e ) {
338
- log .error ("Cannot init the writer for time series file path '{}'." , filePathString , e );
339
- return Optional .empty ();
288
+ filePathString ));
340
289
} catch (IllegalArgumentException e ) {
341
290
log .error (
342
291
"Error during extraction of meta information from file name '{}'." , filePathString , e );
343
292
return Optional .empty ();
344
293
}
345
294
}
346
295
296
+ /**
297
+ * Initialises a reader to get grip on the file that contains mapping information between
298
+ * coordinate id and actual coordinate
299
+ *
300
+ * @return A {@link BufferedReader}
301
+ * @throws FileNotFoundException If the file is not present
302
+ */
303
+ public BufferedReader initIdCoordinateReader () throws FileNotFoundException {
304
+ String filePath = entityPersistenceNamingStrategy .getIdCoordinateEntityName ();
305
+ return initReader (filePath );
306
+ }
307
+
308
+ /**
309
+ * Returns a set of relative paths strings to time series files, with respect to the base folder
310
+ * path
311
+ *
312
+ * @return A set of relative paths to time series files, with respect to the base folder path
313
+ */
314
+ private Set <String > getIndividualTimeSeriesFilePaths () {
315
+ Path baseDirectoryPath =
316
+ Paths .get (
317
+ FilenameUtils .getFullPath (baseDirectoryName )
318
+ + FilenameUtils .getName (baseDirectoryName ));
319
+ try (Stream <Path > pathStream = Files .walk (baseDirectoryPath )) {
320
+ return pathStream
321
+ .map (baseDirectoryPath ::relativize )
322
+ .filter (
323
+ path -> {
324
+ String withoutEnding = removeFileEnding (path .toString ());
325
+ return entityPersistenceNamingStrategy
326
+ .getIndividualTimeSeriesPattern ()
327
+ .matcher (withoutEnding )
328
+ .matches ();
329
+ })
330
+ .map (Path ::toString )
331
+ .collect (Collectors .toSet ());
332
+ } catch (IOException e ) {
333
+ log .error ("Unable to determine time series files readers for time series." , e );
334
+ return Collections .emptySet ();
335
+ }
336
+ }
337
+
347
338
/**
348
339
* Removes the file ending from input string
349
340
*
@@ -414,63 +405,6 @@ public void shutdown() {
414
405
});
415
406
}
416
407
417
- /**
418
- * Class to bundle all information, that are necessary to read a single time series
419
- *
420
- * @deprecated Use the {@link CsvIndividualTimeSeriesMetaInformation} and build reader on demand
421
- */
422
- @ Deprecated
423
- public static class TimeSeriesReadingData {
424
- private final UUID uuid ;
425
- private final ColumnScheme columnScheme ;
426
- private final BufferedReader reader ;
427
-
428
- public TimeSeriesReadingData (UUID uuid , ColumnScheme columnScheme , BufferedReader reader ) {
429
- this .uuid = uuid ;
430
- this .columnScheme = columnScheme ;
431
- this .reader = reader ;
432
- }
433
-
434
- public UUID getUuid () {
435
- return uuid ;
436
- }
437
-
438
- public ColumnScheme getColumnScheme () {
439
- return columnScheme ;
440
- }
441
-
442
- public BufferedReader getReader () {
443
- return reader ;
444
- }
445
-
446
- @ Override
447
- public boolean equals (Object o ) {
448
- if (this == o ) return true ;
449
- if (!(o instanceof TimeSeriesReadingData )) return false ;
450
- TimeSeriesReadingData that = (TimeSeriesReadingData ) o ;
451
- return uuid .equals (that .uuid )
452
- && columnScheme == that .columnScheme
453
- && reader .equals (that .reader );
454
- }
455
-
456
- @ Override
457
- public int hashCode () {
458
- return Objects .hash (uuid , columnScheme , reader );
459
- }
460
-
461
- @ Override
462
- public String toString () {
463
- return "TimeSeriesReadingData{"
464
- + "uuid="
465
- + uuid
466
- + ", columnScheme="
467
- + columnScheme
468
- + ", reader="
469
- + reader
470
- + '}' ;
471
- }
472
- }
473
-
474
408
/** Enhancing the {@link IndividualTimeSeriesMetaInformation} with the full path to csv file */
475
409
public static class CsvIndividualTimeSeriesMetaInformation
476
410
extends IndividualTimeSeriesMetaInformation {
0 commit comments