Search in sources :

Example 1 with Authorizations

use of org.vertexium.Authorizations in project vertexium by visallo.

the class ExecuteCypherQuery method run.

private int run(String[] args) throws Exception {
    Parameters params = new Parameters();
    JCommander j = new JCommander(params, args);
    if (params.help) {
        j.usage();
        return -1;
    }
    Map<String, String> config = ConfigurationUtils.loadConfig(params.getConfigFileNames(), params.configPropertyPrefix);
    Graph graph = new GraphFactory().createGraph(config);
    Authorizations authorizations = params.getAuthorizations(graph);
    VertexiumCypherQueryContext ctx = new CliVertexiumCypherQueryContext(graph, authorizations);
    CliVertexiumCypherQueryContext.setLabelPropertyName(params.cypherLabelProperty);
    CypherCompilerContext compilerContext = new CypherCompilerContext(ctx.getFunctions());
    long startTime = System.currentTimeMillis();
    String queryString = params.query.stream().collect(Collectors.joining(" "));
    VertexiumCypherQuery query = VertexiumCypherQuery.parse(compilerContext, queryString);
    VertexiumCypherResult results = query.execute(ctx);
    results.stream().forEach(row -> {
        results.getColumnNames().forEach(column -> {
            System.out.println(row.getByName(column));
        });
    });
    long endTime = System.currentTimeMillis();
    LOGGER.info("total time: %.2fs", ((double) (endTime - startTime) / 1000.0));
    return 0;
}
Also used : VertexiumCypherResult(org.vertexium.cypher.VertexiumCypherResult) GraphFactory(org.vertexium.GraphFactory) Authorizations(org.vertexium.Authorizations) Graph(org.vertexium.Graph) CypherCompilerContext(org.vertexium.cypher.ast.CypherCompilerContext) JCommander(com.beust.jcommander.JCommander) VertexiumCypherQueryContext(org.vertexium.cypher.VertexiumCypherQueryContext) VertexiumCypherQuery(org.vertexium.cypher.VertexiumCypherQuery)

Example 2 with Authorizations

use of org.vertexium.Authorizations in project vertexium by visallo.

the class GraphGlue method createGraph.

private void createGraph() {
    InMemoryGraph graph = InMemoryGraph.create();
    Authorizations authorizations = graph.createAuthorizations();
    ctx = new TestVertexiumCypherQueryContext(graph, authorizations);
}
Also used : InMemoryGraph(org.vertexium.inmemory.InMemoryGraph) Authorizations(org.vertexium.Authorizations) TestVertexiumCypherQueryContext(org.vertexium.cypher.TestVertexiumCypherQueryContext)

Example 3 with Authorizations

use of org.vertexium.Authorizations in project vertexium by visallo.

the class SetAuthsCommand method execute.

@Override
public Object execute(List<String> args) {
    List<String> auths = parseAuths(args);
    Authorizations authorizations = VertexiumScript.getGraph().createAuthorizations(auths.toArray(new String[auths.size()]));
    VertexiumScript.setAuthorizations(authorizations);
    return authorizations;
}
Also used : Authorizations(org.vertexium.Authorizations)

Aggregations

Authorizations (org.vertexium.Authorizations)3 JCommander (com.beust.jcommander.JCommander)1 Graph (org.vertexium.Graph)1 GraphFactory (org.vertexium.GraphFactory)1 TestVertexiumCypherQueryContext (org.vertexium.cypher.TestVertexiumCypherQueryContext)1 VertexiumCypherQuery (org.vertexium.cypher.VertexiumCypherQuery)1 VertexiumCypherQueryContext (org.vertexium.cypher.VertexiumCypherQueryContext)1 VertexiumCypherResult (org.vertexium.cypher.VertexiumCypherResult)1 CypherCompilerContext (org.vertexium.cypher.ast.CypherCompilerContext)1 InMemoryGraph (org.vertexium.inmemory.InMemoryGraph)1