use of nl.knaw.huygens.timbuctoo.v5.jsonfilebackeddata.JsonFileBackedData in project timbuctoo by HuygensING.
the class FileSystemDataStorage method loadDataSetMetaData.
@Override
public Map<String, Set<DataSetMetaData>> loadDataSetMetaData() throws IOException {
Map<String, Set<DataSetMetaData>> metaDataSet = Maps.newHashMap();
File[] directories = new File(dataSetMetadataLocation).listFiles(File::isDirectory);
for (int i = 0; i < directories.length; i++) {
String dirName = directories[i].toString();
String currentOwnerId = dirName.substring(dirName.lastIndexOf("/") + 1, dirName.length());
Set<DataSetMetaData> tempMetaDataSet = new HashSet<>();
try (Stream<Path> fileStream = Files.walk(directories[i].toPath())) {
Set<Path> paths = fileStream.filter(current -> Files.isDirectory(current)).collect(Collectors.toSet());
for (Path path : paths) {
File tempFile = new File(path.toString() + "/metaData.json");
if (tempFile.exists()) {
JsonFileBackedData<BasicDataSetMetaData> metaDataFromFile = null;
metaDataFromFile = JsonFileBackedData.getOrCreate(tempFile, null, new TypeReference<BasicDataSetMetaData>() {
});
tempMetaDataSet.add(metaDataFromFile.getData());
}
}
}
metaDataSet.put(currentOwnerId, tempMetaDataSet);
}
return metaDataSet;
}
Aggregations