Skip to content

Commit 606f731

Browse files
committed
Rearranging methods
1 parent 86c4d1f commit 606f731

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java

+41-41
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public Optional<IndividualTimeSeriesMetaInformation> getIndividualTimeSeriesMeta
221221
}
222222

223223
/**
224-
* Receive the information for specific time series They are given back grouped by the column
224+
* Receive the information for specific time series. They are given back grouped by the column
225225
* scheme in order to allow for accounting the different content types.
226226
*
227227
* @param columnSchemes the column schemes to initialize readers for. If no scheme is given, all
@@ -244,6 +244,46 @@ public Optional<IndividualTimeSeriesMetaInformation> getIndividualTimeSeriesMeta
244244
CsvIndividualTimeSeriesMetaInformation::getColumnScheme, Collectors.toSet()));
245245
}
246246

247+
/**
248+
* Removes the file ending from input string
249+
*
250+
* @param input String to manipulate
251+
* @return input without possible ending
252+
*/
253+
private String removeFileEnding(String input) {
254+
return input.replaceAll(FILE_ENDING + "$", "");
255+
}
256+
257+
/**
258+
* Returns a set of relative paths strings to time series files, with respect to the base folder
259+
* path
260+
*
261+
* @return A set of relative paths to time series files, with respect to the base folder path
262+
*/
263+
private Set<String> getIndividualTimeSeriesFilePaths() {
264+
Path baseDirectoryPath =
265+
Paths.get(
266+
FilenameUtils.getFullPath(baseDirectoryName)
267+
+ FilenameUtils.getName(baseDirectoryName));
268+
try (Stream<Path> pathStream = Files.walk(baseDirectoryPath)) {
269+
return pathStream
270+
.map(baseDirectoryPath::relativize)
271+
.filter(
272+
path -> {
273+
String withoutEnding = removeFileEnding(path.toString());
274+
return entityPersistenceNamingStrategy
275+
.getIndividualTimeSeriesPattern()
276+
.matcher(withoutEnding)
277+
.matches();
278+
})
279+
.map(Path::toString)
280+
.collect(Collectors.toSet());
281+
} catch (IOException e) {
282+
log.error("Unable to determine time series files readers for time series.", e);
283+
return Collections.emptySet();
284+
}
285+
}
286+
247287
/**
248288
* Compose the needed information for reading in a single time series. If the file points to a
249289
* non-individual time series or a time series of a column scheme other than the specified ones,
@@ -305,46 +345,6 @@ public BufferedReader initIdCoordinateReader() throws FileNotFoundException {
305345
return initReader(filePath);
306346
}
307347

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-
338-
/**
339-
* Removes the file ending from input string
340-
*
341-
* @param input String to manipulate
342-
* @return input without possible ending
343-
*/
344-
private String removeFileEnding(String input) {
345-
return input.replaceAll(FILE_ENDING + "$", "");
346-
}
347-
348348
/**
349349
* Builds a new file definition consisting of file name and head line elements
350350
*

0 commit comments

Comments
 (0)