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);
}
}
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);
}
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;
}
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);
}
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;
}
Aggregations