use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.
the class GraphExporterImpl method exportDataOntology.
private void exportDataOntology(List<Study> studies, String baseDir) throws StudyImporterException {
try {
ExporterRDF studyExporter = new ExporterRDF();
OutputStreamWriter writer = openStream(baseDir + "globi.nq.gz");
int total = studies.size();
int count = 1;
for (Study study : studies) {
studyExporter.exportStudy(study, writer, true);
if (count % 50 == 0) {
LOG.info("added triples for [" + count + "] of [" + total + "] studies...");
}
count++;
}
LOG.info("adding triples for [" + total + "] of [" + total + "] studies.");
LOG.info("writing nquads archive...");
closeStream(baseDir + "globi.nq.gz", writer);
} catch (IOException e) {
throw new StudyImporterException("failed to export as owl", e);
}
}
use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.
the class GraphExporterImpl method exportNames.
private void exportNames(List<Study> studies, String baseDir, StudyExporter exporter, String filename) throws StudyImporterException {
try {
String filePath = baseDir + filename;
OutputStreamWriter writer = openStream(filePath);
for (Study study : studies) {
boolean includeHeader = studies.indexOf(study) == 0;
exporter.exportStudy(study, writer, includeHeader);
}
closeStream(filePath, writer);
} catch (IOException e) {
throw new StudyImporterException("failed to export unmatched source taxa", e);
}
}
use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.
the class Normalizer method importData.
void importData(GraphDatabaseService graphService, String cacheDir) {
NodeFactoryNeo4j factory = new NodeFactoryNeo4j(graphService);
factory.setEcoregionFinder(getEcoregionFinder());
factory.setDoiResolver(new DOIResolverImpl());
try {
CacheFactory cacheFactory = dataset -> new CacheLocalReadonly(dataset.getNamespace(), cacheDir);
DatasetFinder finder = new DatasetFinderLocal(cacheDir, cacheFactory);
StudyImporter importer = new StudyImporterForGitHubData(new ParserFactoryLocal(), factory, finder);
importer.setDataset(new DatasetLocal());
importer.setLogger(new StudyImportLogger());
importer.importStudy();
} catch (StudyImporterException e) {
LOG.error("problem encountered while importing [" + StudyImporterForGitHubData.class.getName() + "]", e);
}
EcoregionFinder regionFinder = getEcoregionFinder();
if (regionFinder != null) {
regionFinder.shutdown();
}
}
use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.
the class GitHubImporterFactory method createImporter.
public StudyImporter createImporter(Dataset dataset, final NodeFactory nodeFactory) throws StudyImporterException {
Class<? extends StudyImporter> anImporter = findImporterFor(dataset);
try {
Constructor<? extends StudyImporter> constructor = anImporter.getConstructor(ParserFactory.class, NodeFactory.class);
ParserFactoryForDataset parserFactory = new ParserFactoryForDataset(dataset);
StudyImporter studyImporter = constructor.newInstance(parserFactory, new NodeFactoryWithDatasetContext(nodeFactory, dataset));
studyImporter.setDataset(dataset);
return studyImporter;
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
throw new StudyImporterException("failed to instantiate importer for [" + dataset.getNamespace() + "]", e);
}
}
use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.
the class GraphExporterImpl method exportDarwinCoreArchive.
private void exportDarwinCoreArchive(List<Study> studies, String pathPrefix, Map<String, DarwinCoreExporter> exporters) throws StudyImporterException {
try {
FileUtils.forceMkdir(new File(pathPrefix));
FileWriter darwinCoreMeta = writeMetaHeader(pathPrefix);
for (Map.Entry<String, DarwinCoreExporter> exporter : exporters.entrySet()) {
export(studies, pathPrefix, exporter.getKey(), exporter.getValue(), darwinCoreMeta);
}
writeMetaFooter(darwinCoreMeta);
} catch (IOException e) {
throw new StudyImporterException("failed to export result to csv file", e);
}
}
Aggregations