Search in sources :

Example 16 with VertexiumException

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

the class AccumuloAuthorizations method canRead.

@Override
public boolean canRead(Visibility visibility) {
    Preconditions.checkNotNull(visibility, "visibility is required");
    // this is just a shortcut so that we don't need to construct evaluators and visibility objects to check for an empty string.
    if (visibility.getVisibilityString().length() == 0) {
        return true;
    }
    VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(new org.apache.accumulo.core.security.Authorizations(this.getAuthorizations()));
    ColumnVisibility columnVisibility = new ColumnVisibility(visibility.getVisibilityString());
    try {
        return visibilityEvaluator.evaluate(columnVisibility);
    } catch (VisibilityParseException e) {
        throw new VertexiumException("could not evaluate visibility " + visibility.getVisibilityString(), e);
    }
}
Also used : VisibilityEvaluator(org.apache.accumulo.core.security.VisibilityEvaluator) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) VisibilityParseException(org.apache.accumulo.core.security.VisibilityParseException) VertexiumException(org.vertexium.VertexiumException)

Example 17 with VertexiumException

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

the class ExpressionExecutor method executeExpression.

public Object executeExpression(VertexiumCypherQueryContext ctx, CypherAstBase expression, ExpressionScope scope) {
    if (expression == null) {
        return null;
    }
    if (expression instanceof CypherExpression) {
        if (expression instanceof CypherBinaryExpression) {
            return executeBinaryExpression(ctx, (CypherBinaryExpression) expression, scope);
        } else if (expression instanceof CypherComparisonExpression) {
            return executeComparisonExpression(ctx, (CypherComparisonExpression) expression, scope);
        } else if (expression instanceof CypherUnaryExpression) {
            return executeUnaryExpression(ctx, (CypherUnaryExpression) expression, scope);
        } else if (expression instanceof CypherTrueExpression) {
            return true;
        } else if (expression instanceof CypherNegateExpression) {
            return executeNegateExpression(ctx, (CypherNegateExpression) expression, scope);
        }
        throw new VertexiumCypherNotImplemented("" + expression);
    }
    if (expression instanceof CypherListLiteral) {
        // noinspection unchecked
        CypherListLiteral<? extends CypherAstBase> list = (CypherListLiteral<? extends CypherAstBase>) expression;
        return executeList(ctx, list, scope);
    }
    if (expression instanceof CypherLiteral) {
        CypherLiteral literal = (CypherLiteral) expression;
        return literal.getValue();
    }
    if (expression instanceof CypherVariable) {
        CypherVariable variable = (CypherVariable) expression;
        return executeObject(ctx, executeVariable(ctx, variable, scope), scope);
    }
    if (expression instanceof CypherLookup) {
        CypherLookup lookup = (CypherLookup) expression;
        return executeLookup(ctx, lookup, scope);
    }
    if (expression instanceof CypherFunctionInvocation) {
        CypherFunctionInvocation functionInvocation = (CypherFunctionInvocation) expression;
        return executeFunctionInvocation(ctx, functionInvocation, scope);
    }
    if (expression instanceof CypherIn) {
        CypherIn in = (CypherIn) expression;
        return executeIn(ctx, in, scope);
    }
    if (expression instanceof CypherArrayAccess) {
        CypherArrayAccess arrayAccess = (CypherArrayAccess) expression;
        return executeArrayAccess(ctx, arrayAccess, scope);
    }
    if (expression instanceof CypherArraySlice) {
        CypherArraySlice arraySlice = (CypherArraySlice) expression;
        return executeArraySlice(ctx, arraySlice, scope);
    }
    if (expression instanceof CypherParameter) {
        CypherParameter parameter = (CypherParameter) expression;
        return executeParameter(ctx, parameter);
    }
    if (expression instanceof CypherIsNull) {
        CypherIsNull isNull = (CypherIsNull) expression;
        return executeIsNull(ctx, isNull, scope);
    }
    if (expression instanceof CypherIsNotNull) {
        CypherIsNotNull isNotNull = (CypherIsNotNull) expression;
        return executeIsNotNull(ctx, isNotNull, scope);
    }
    if (expression instanceof CypherListComprehension) {
        CypherListComprehension listComprehension = (CypherListComprehension) expression;
        return executeListComprehension(ctx, listComprehension, scope);
    }
    if (expression instanceof CypherStringMatch) {
        CypherStringMatch startWith = (CypherStringMatch) expression;
        return executeStringMatch(ctx, startWith, scope);
    }
    if (expression instanceof CypherPatternComprehension) {
        CypherPatternComprehension patternComprehension = (CypherPatternComprehension) expression;
        VertexiumCypherScope matchScope = scope instanceof VertexiumCypherScope ? (VertexiumCypherScope) scope : VertexiumCypherScope.newSingleItemScope((VertexiumCypherScope.Item) scope);
        VertexiumCypherScope results = ctx.getMatchClauseExecutor().execute(ctx, Lists.newArrayList(patternComprehension.getMatchClause()), matchScope);
        return results.stream().map(item -> executeExpression(ctx, patternComprehension.getExpression(), item));
    }
    throw new VertexiumException("not implemented \"" + expression.getClass().getName() + "\": " + expression);
}
Also used : VertexiumCypherNotImplemented(org.vertexium.cypher.exceptions.VertexiumCypherNotImplemented) VertexiumException(org.vertexium.VertexiumException) VertexiumCypherScope(org.vertexium.cypher.VertexiumCypherScope)

Example 18 with VertexiumException

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

the class QueryExecutor method execute.

private VertexiumCypherScope execute(VertexiumCypherQueryContext ctx, ImmutableList<CypherClause> clauses, AtomicInteger clauseIndex, VertexiumCypherScope previousScope) {
    VertexiumCypherScope results;
    CypherClause clause = clauses.get(clauseIndex.get());
    if (clause instanceof CypherCreateClause) {
        results = ctx.getCreateClauseExecutor().execute(ctx, (CypherCreateClause) clause, previousScope);
    } else if (clause instanceof CypherReturnClause) {
        results = ctx.getReturnClauseExecutor().execute(ctx, (CypherReturnClause) clause, previousScope);
    } else if (clause instanceof CypherMatchClause) {
        List<CypherMatchClause> matchClauses = getSimilarClauses(clauses, clauseIndex.get(), CypherMatchClause.class);
        results = ctx.getMatchClauseExecutor().execute(ctx, matchClauses, previousScope);
        clauseIndex.addAndGet(matchClauses.size() - 1);
    } else if (clause instanceof CypherUnwindClause) {
        List<CypherUnwindClause> unwindClauses = getSimilarClauses(clauses, clauseIndex.get(), CypherUnwindClause.class);
        results = ctx.getUnwindClauseExecutor().execute(ctx, unwindClauses, previousScope);
        clauseIndex.addAndGet(unwindClauses.size() - 1);
    } else if (clause instanceof CypherWithClause) {
        results = ctx.getWithClauseExecutor().execute(ctx, (CypherWithClause) clause, previousScope);
    } else if (clause instanceof CypherMergeClause) {
        results = ctx.getMergeClauseExecutor().execute(ctx, (CypherMergeClause) clause, previousScope);
    } else if (clause instanceof CypherDeleteClause) {
        results = ctx.getDeleteClauseExecutor().execute(ctx, (CypherDeleteClause) clause, previousScope);
    } else if (clause instanceof CypherSetClause) {
        results = ctx.getSetClauseExecutor().execute(ctx, (CypherSetClause) clause, previousScope);
    } else if (clause instanceof CypherRemoveClause) {
        results = ctx.getRemoveClauseExecutor().execute(ctx, (CypherRemoveClause) clause, previousScope);
    } else {
        throw new VertexiumException("clause not implemented \"" + clause.getClass().getName() + "\": " + clause);
    }
    return results;
}
Also used : VertexiumException(org.vertexium.VertexiumException) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VertexiumCypherScope(org.vertexium.cypher.VertexiumCypherScope)

Example 19 with VertexiumException

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

the class LabelsFunction method invoke.

@Override
public Object invoke(VertexiumCypherQueryContext ctx, CypherAstBase[] arguments, ExpressionScope scope) {
    CypherAstBase lookup = arguments[0];
    Object item = ctx.getExpressionExecutor().executeExpression(ctx, lookup, scope);
    if (item == null) {
        throw new VertexiumException("Could not find Vertex using " + lookup);
    }
    if (item instanceof Vertex) {
        Vertex vertex = (Vertex) item;
        return ctx.getVertexLabels(vertex);
    }
    if (item instanceof Edge) {
        Edge edge = (Edge) item;
        return Lists.newArrayList(edge.getLabel());
    }
    throw new VertexiumCypherTypeErrorException(item, Vertex.class, Edge.class);
}
Also used : Vertex(org.vertexium.Vertex) VertexiumCypherTypeErrorException(org.vertexium.cypher.exceptions.VertexiumCypherTypeErrorException) CypherAstBase(org.vertexium.cypher.ast.model.CypherAstBase) Edge(org.vertexium.Edge) VertexiumException(org.vertexium.VertexiumException)

Example 20 with VertexiumException

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

the class ParametersBase method addConfigDirectoryToConfigFileNames.

private static List<String> addConfigDirectoryToConfigFileNames(String configDirectory) {
    File dir = new File(configDirectory);
    if (!dir.exists()) {
        throw new VertexiumException("Directory does not exist: " + dir.getAbsolutePath());
    }
    List<String> files = Lists.newArrayList(dir.listFiles()).stream().filter(File::isFile).map(File::getName).filter(f -> f.endsWith(".properties")).collect(Collectors.toList());
    Collections.sort(files);
    files = files.stream().map(f -> new File(dir, f).getAbsolutePath()).collect(Collectors.toList());
    return files;
}
Also used : List(java.util.List) Lists(com.google.common.collect.Lists) Graph(org.vertexium.Graph) VertexiumException(org.vertexium.VertexiumException) Parameter(com.beust.jcommander.Parameter) Authorizations(org.vertexium.Authorizations) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) File(java.io.File) ArrayList(java.util.ArrayList) File(java.io.File) VertexiumException(org.vertexium.VertexiumException)

Aggregations

VertexiumException (org.vertexium.VertexiumException)34 Aggregation (org.elasticsearch.search.aggregations.Aggregation)6 MultiBucketsAggregation (org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)3 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 DataTableRowKey (org.vertexium.accumulo.keys.DataTableRowKey)3 StreamingPropertyValue (org.vertexium.property.StreamingPropertyValue)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 List (java.util.List)2 ScannerBase (org.apache.accumulo.core.client.ScannerBase)2 Span (org.apache.accumulo.core.trace.Span)2 GeoHashGrid (org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGrid)2 InternalGeoHashGrid (org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid)2 Histogram (org.elasticsearch.search.aggregations.bucket.histogram.Histogram)2 InternalDateHistogram (org.elasticsearch.search.aggregations.bucket.histogram.InternalDateHistogram)2 InternalHistogram (org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram)2