Search in sources :

Example 1 with ListExpression

use of org.apache.atlas.groovy.ListExpression in project incubator-atlas by apache.

the class GremlinExpressionFactory method typeTestExpressionUsingInFilter.

private List<GroovyExpression> typeTestExpressionUsingInFilter(GraphPersistenceStrategies s, GroovyExpression parent, final String typeName) throws AtlasException {
    List<GroovyExpression> typeNames = new ArrayList<>();
    typeNames.add(new LiteralExpression(typeName));
    Map<TYPE_FILTER, String> filters = new HashMap<TYPE_FILTER, String>() {

        {
            put(TYPE_FILTER.SUPERTYPE, typeName);
        }
    };
    ImmutableList<String> subTypes = TypeSystem.getInstance().getTypeNames(filters);
    if (!subTypes.isEmpty()) {
        for (String subType : subTypes) {
            typeNames.add(new LiteralExpression(subType));
        }
    }
    GroovyExpression inFilterExpr = generateHasExpression(s, parent, s.typeAttributeName(), IN_OPERATOR, new ListExpression(typeNames), null);
    return Collections.singletonList(inFilterExpr);
}
Also used : HashMap(java.util.HashMap) LiteralExpression(org.apache.atlas.groovy.LiteralExpression) ListExpression(org.apache.atlas.groovy.ListExpression) ArrayList(java.util.ArrayList) GroovyExpression(org.apache.atlas.groovy.GroovyExpression) TYPE_FILTER(org.apache.atlas.typesystem.types.cache.TypeCache.TYPE_FILTER)

Example 2 with ListExpression

use of org.apache.atlas.groovy.ListExpression in project incubator-atlas by apache.

the class Gremlin2ExpressionFactory method generateSelectExpression.

@Override
public GroovyExpression generateSelectExpression(GroovyExpression parent, List<LiteralExpression> sourceNames, List<GroovyExpression> srcExprs) {
    GroovyExpression srcNamesExpr = new ListExpression(sourceNames);
    List<GroovyExpression> selectArgs = new ArrayList<>();
    selectArgs.add(srcNamesExpr);
    for (GroovyExpression expr : srcExprs) {
        selectArgs.add(new ClosureExpression(expr));
    }
    return new FunctionCallExpression(TraversalStepType.MAP_TO_VALUE, parent, SELECT_METHOD, selectArgs);
}
Also used : ListExpression(org.apache.atlas.groovy.ListExpression) ArrayList(java.util.ArrayList) GroovyExpression(org.apache.atlas.groovy.GroovyExpression) ClosureExpression(org.apache.atlas.groovy.ClosureExpression) FunctionCallExpression(org.apache.atlas.groovy.FunctionCallExpression)

Example 3 with ListExpression

use of org.apache.atlas.groovy.ListExpression in project incubator-atlas by apache.

the class OptimizationContext method getDefineResultVariableStmt.

public GroovyExpression getDefineResultVariableStmt() {
    GroovyExpression castExpression = new TypeCoersionExpression(new ListExpression(), "Set");
    GroovyExpression resultVarDef = new VariableAssignmentExpression(RESULT_VARIABLE, castExpression);
    return resultVarDef;
}
Also used : TypeCoersionExpression(org.apache.atlas.groovy.TypeCoersionExpression) ListExpression(org.apache.atlas.groovy.ListExpression) GroovyExpression(org.apache.atlas.groovy.GroovyExpression) VariableAssignmentExpression(org.apache.atlas.groovy.VariableAssignmentExpression)

Aggregations

GroovyExpression (org.apache.atlas.groovy.GroovyExpression)3 ListExpression (org.apache.atlas.groovy.ListExpression)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 ClosureExpression (org.apache.atlas.groovy.ClosureExpression)1 FunctionCallExpression (org.apache.atlas.groovy.FunctionCallExpression)1 LiteralExpression (org.apache.atlas.groovy.LiteralExpression)1 TypeCoersionExpression (org.apache.atlas.groovy.TypeCoersionExpression)1 VariableAssignmentExpression (org.apache.atlas.groovy.VariableAssignmentExpression)1 TYPE_FILTER (org.apache.atlas.typesystem.types.cache.TypeCache.TYPE_FILTER)1