use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class Gremlin3ExpressionFactory method escapePropertyValue.
private GroovyExpression escapePropertyValue(GroovyExpression propertyValue) {
GroovyExpression ret = propertyValue;
if (propertyValue instanceof LiteralExpression) {
LiteralExpression exp = (LiteralExpression) propertyValue;
if (exp != null && exp.getValue() instanceof String) {
String stringValue = (String) exp.getValue();
// replace '*' with ".*", replace '?' with '.'
stringValue = stringValue.replaceAll("\\*", ".*").replaceAll("\\?", ".");
ret = new LiteralExpression(stringValue);
}
}
return ret;
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class Gremlin3ExpressionFactory method generateLoopExpression.
@Override
public GroovyExpression generateLoopExpression(GroovyExpression parent, GraphPersistenceStrategies s, IDataType dataType, GroovyExpression loopExpr, String alias, Integer times) {
GroovyExpression emitExpr = generateLoopEmitExpression(s, dataType);
GroovyExpression result = new FunctionCallExpression(TraversalStepType.BRANCH, parent, REPEAT_METHOD, loopExpr);
if (times != null) {
GroovyExpression timesExpr = new LiteralExpression(times);
result = new FunctionCallExpression(TraversalStepType.SIDE_EFFECT, result, TIMES_METHOD, timesExpr);
}
result = new FunctionCallExpression(TraversalStepType.SIDE_EFFECT, result, EMIT_METHOD, emitExpr);
return result;
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class Gremlin3ExpressionFactory method generateOrderByExpression.
@Override
public GroovyExpression generateOrderByExpression(GroovyExpression parent, List<GroovyExpression> translatedOrderBy, boolean isAscending) {
GroovyExpression orderByExpr = translatedOrderBy.get(0);
GroovyExpression orderByClosure = new ClosureExpression(orderByExpr);
GroovyExpression orderByClause = new TypeCoersionExpression(orderByClosure, FUNCTION_CLASS);
GroovyExpression aExpr = new IdentifierExpression("a");
GroovyExpression bExpr = new IdentifierExpression("b");
GroovyExpression aCompExpr = new FunctionCallExpression(new FunctionCallExpression(aExpr, TO_STRING_METHOD), TO_LOWER_CASE_METHOD);
GroovyExpression bCompExpr = new FunctionCallExpression(new FunctionCallExpression(bExpr, TO_STRING_METHOD), TO_LOWER_CASE_METHOD);
GroovyExpression comparisonExpr = null;
if (isAscending) {
comparisonExpr = new ComparisonOperatorExpression(aCompExpr, bCompExpr);
} else {
comparisonExpr = new ComparisonOperatorExpression(bCompExpr, aCompExpr);
}
ClosureExpression comparisonFunction = new ClosureExpression(comparisonExpr, "a", "b");
FunctionCallExpression orderCall = new FunctionCallExpression(TraversalStepType.BARRIER, parent, ORDER_METHOD);
return new FunctionCallExpression(TraversalStepType.SIDE_EFFECT, orderCall, BY_METHOD, orderByClause, comparisonFunction);
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class GremlinExpressionFactory method fillVarWithTypeInstances.
private GroovyExpression fillVarWithTypeInstances(GraphPersistenceStrategies s, String typeName, String fillVar) {
GroovyExpression graphExpr = getAllVerticesExpr();
GroovyExpression typeAttributeNameExpr = new LiteralExpression(s.typeAttributeName());
GroovyExpression typeNameExpr = new LiteralExpression(typeName);
GroovyExpression hasExpr = new FunctionCallExpression(graphExpr, HAS_METHOD, typeAttributeNameExpr, typeNameExpr);
GroovyExpression fillExpr = new FunctionCallExpression(hasExpr, FILL_METHOD, new IdentifierExpression(fillVar));
return fillExpr;
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class GremlinExpressionFactory method fillVarWithSubTypeInstances.
private GroovyExpression fillVarWithSubTypeInstances(GraphPersistenceStrategies s, String typeName, String fillVar) {
GroovyExpression graphExpr = getAllVerticesExpr();
GroovyExpression superTypeAttributeNameExpr = new LiteralExpression(s.superTypeAttributeName());
GroovyExpression typeNameExpr = new LiteralExpression(typeName);
GroovyExpression hasExpr = new FunctionCallExpression(graphExpr, HAS_METHOD, superTypeAttributeNameExpr, typeNameExpr);
GroovyExpression fillExpr = new FunctionCallExpression(hasExpr, FILL_METHOD, new IdentifierExpression(fillVar));
return fillExpr;
}
Aggregations