use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin2ExpressionFactory method generateOrderByExpression.
@Override
public GroovyExpression generateOrderByExpression(GroovyExpression parent, List<GroovyExpression> translatedOrderBy, boolean isAscending) {
GroovyExpression aPropertyExpr = translatedOrderBy.get(0);
GroovyExpression bPropertyExpr = translatedOrderBy.get(1);
GroovyExpression aPropertyNotNull = new ComparisonExpression(aPropertyExpr, ComparisonOperator.NOT_EQUALS, LiteralExpression.NULL);
GroovyExpression bPropertyNotNull = new ComparisonExpression(bPropertyExpr, ComparisonOperator.NOT_EQUALS, LiteralExpression.NULL);
GroovyExpression aCondition = new TernaryOperatorExpression(aPropertyNotNull, new FunctionCallExpression(aPropertyExpr, TO_LOWER_CASE_METHOD), aPropertyExpr);
GroovyExpression bCondition = new TernaryOperatorExpression(bPropertyNotNull, new FunctionCallExpression(bPropertyExpr, TO_LOWER_CASE_METHOD), bPropertyExpr);
GroovyExpression comparisonFunction = null;
if (isAscending) {
comparisonFunction = new ComparisonOperatorExpression(aCondition, bCondition);
} else {
comparisonFunction = new ComparisonOperatorExpression(bCondition, aCondition);
}
return new FunctionCallExpression(TraversalStepType.BARRIER, parent, ORDER_METHOD, new ClosureExpression(comparisonFunction));
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin2ExpressionFactory method generateGetSelectedValueExpression.
@Override
public GroovyExpression generateGetSelectedValueExpression(LiteralExpression key, GroovyExpression rowMap) {
rowMap = new CastExpression(rowMap, "Row");
GroovyExpression getExpr = new FunctionCallExpression(rowMap, "getColumn", key);
return getExpr;
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin2ExpressionFactory method typeTestExpression.
@Override
public GroovyExpression typeTestExpression(GraphPersistenceStrategies s, String typeName, GroovyExpression itRef) {
GroovyExpression superTypeAttrExpr = new FieldExpression(itRef, s.superTypeAttributeName());
GroovyExpression typeNameExpr = new LiteralExpression(typeName);
GroovyExpression isSuperTypeExpr = new FunctionCallExpression(superTypeAttrExpr, CONTAINS, typeNameExpr);
GroovyExpression superTypeMatchesExpr = new TernaryOperatorExpression(superTypeAttrExpr, isSuperTypeExpr, LiteralExpression.FALSE);
GroovyExpression typeAttrExpr = new FieldExpression(itRef, s.typeAttributeName());
GroovyExpression typeMatchesExpr = new ComparisonExpression(typeAttrExpr, ComparisonOperator.EQUALS, typeNameExpr);
return new LogicalExpression(typeMatchesExpr, LogicalOperator.OR, superTypeMatchesExpr);
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class GremlinExpressionFactory method removeExtraMapFromPathInResult.
public GroovyExpression removeExtraMapFromPathInResult(GroovyExpression parent) {
GroovyExpression listItem = getItVariable();
GroovyExpression tailExpr = new FunctionCallExpression(listItem, "tail");
return new FunctionCallExpression(parent, "collect", new ClosureExpression(tailExpr));
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class SplitPointFinder method isRequiredInResultExpression.
private boolean isRequiredInResultExpression(AbstractFunctionExpression expr) {
TraversalStepType type = expr.getType();
if (!TYPES_REQUIRED_IN_RESULT_EXPRESSION.contains(type)) {
return false;
}
if (expr instanceof FunctionCallExpression) {
FunctionCallExpression functionCall = (FunctionCallExpression) expr;
//check if the white list permits this function call. If there is
//no white list, all expressions with the current step type must go in the
//result expression.
WhiteList whiteList = WHITE_LISTS.get(type);
if (whiteList != null && whiteList.contains(functionCall.getFunctionName())) {
return false;
}
}
return true;
}
Aggregations