use of org.eol.globi.tool.CmdGenerateReport in project eol-globi-data by jhpoelen.
the class Elton4N method importWithVersion.
private void importWithVersion(CommandLine cmdLine, String neo4jVersion) throws StudyImporterException {
final String graphDbDirPath = cmdLine.getOptionValue(CmdOptionConstants.OPTION_GRAPHDB_DIR, "graph.db");
Factories factoriesNeo4j = new Factories() {
final GraphServiceFactory factory = new GraphServiceFactoryImpl(new File(graphDbDirPath));
final NodeFactoryFactory nodeFactoryFactory = StringUtils.equals("2", neo4jVersion) ? new NodeFactoryFactoryTransactingOnDatasetNeo4j2(factory) : new NodeFactoryFactoryTransactingOnDatasetNeo4j3(factory);
@Override
public GraphServiceFactory getGraphServiceFactory() {
return factory;
}
@Override
public NodeFactoryFactory getNodeFactoryFactory() {
return nodeFactoryFactory;
}
};
try {
String datasetDir = CmdUtil.getDatasetDir(cmdLine);
GraphServiceFactory graphServiceFactory = factoriesNeo4j.getGraphServiceFactory();
List<Cmd> steps = new ArrayList<>();
LOG.info("processing steps: [" + StringUtils.join(cmdLine.getArgList(), ", ") + "]");
if (cmdLine.getArgList().isEmpty() || cmdLine.getArgList().contains(ELTON_STEP_COMPILE)) {
steps.add(new CmdImportDatasets(factoriesNeo4j.getNodeFactoryFactory(), graphServiceFactory, datasetDir));
}
String exportDir = cmdLine.getOptionValue(CmdOptionConstants.OPTION_EXPORT_DIR, ".");
CmdInterpretTaxa interpretTaxa = createInterpretTaxaCmd(cmdLine, graphServiceFactory, exportDir);
if (cmdLine.getArgList().isEmpty() || cmdLine.getArgList().contains(ELTON_STEP_LINK_NAMES)) {
steps.add(interpretTaxa);
}
if (cmdLine.getArgList().isEmpty() || cmdLine.getArgList().contains(ELTON_STEP_LINK)) {
if (!steps.contains(interpretTaxa)) {
steps.add(interpretTaxa);
}
steps.addAll(Arrays.asList(new CmdIndexTaxa(graphServiceFactory), new CmdIndexTaxonStrings(graphServiceFactory), new CmdGenerateReport(graphServiceFactory.getGraphService())));
}
CmdExportInteractionsTSV interactionsTSVExporter = new CmdExportInteractionsTSV(graphServiceFactory, new File(exportDir));
if (cmdLine.getArgList().isEmpty() || cmdLine.getArgList().contains(ELTON_STEP_PACKAGE_INTERACTIONS_TSV)) {
steps.add(interactionsTSVExporter);
}
if (cmdLine.getArgList().isEmpty() || cmdLine.getArgList().contains(ELTON_STEP_PACKAGE)) {
if (!steps.contains(interactionsTSVExporter)) {
steps.add(interactionsTSVExporter);
}
steps.add(new CmdExport(graphServiceFactory, new File(exportDir)));
}
for (Cmd step : steps) {
step.run();
}
} finally {
HttpUtil.shutdown();
}
}
use of org.eol.globi.tool.CmdGenerateReport in project eol-globi-data by jhpoelen.
the class CypherTestUtil method validate.
public static void validate(CypherQuery cypherQuery, GraphDatabaseService graphDatabaseService) {
try (Transaction tx = graphDatabaseService.beginTx()) {
new NodeFactoryNeo4j2(graphDatabaseService);
new NonResolvingTaxonIndex(graphDatabaseService);
new LinkerTaxonIndex(new GraphServiceFactoryProxy(graphDatabaseService)).index();
CacheService cacheService = new CacheService();
File cacheDir = new File("target/reportGeneration" + UUID.randomUUID());
cacheService.setCacheDir(cacheDir);
CmdGenerateReport reportGenerator = new CmdGenerateReport(graphDatabaseService, cacheService);
reportGenerator.run(NOPLogger.NOP_LOGGER);
Map<String, Object> params = cypherQuery.getParams() == null ? Collections.emptyMap() : new HashMap<>(cypherQuery.getParams());
try {
graphDatabaseService.execute(cypherQuery.getVersionedQuery(), params);
} catch (NullPointerException ex) {
// encountered nullpointer exceptions were caused by initialization of graph database
throw ex;
} catch (RuntimeException ex) {
// work fine in cypher query, but cause parse exception when running programatically
if (!ex.getMessage().contains("Encountered \" \":\" \": \"\"")) {
throw ex;
}
} finally {
FileUtils.deleteQuietly(cacheDir);
}
}
}
Aggregations