Search in sources :

Example 1 with NoSuccess

use of scala.util.parsing.combinator.Parsers.NoSuccess in project incubator-atlas by apache.

the class EntityDiscoveryService method toGremlinQuery.

private GremlinQuery toGremlinQuery(String query, int limit, int offset) throws AtlasBaseException {
    QueryParams params = validateSearchParams(limit, offset);
    Either<NoSuccess, Expression> either = QueryParser.apply(query, params);
    if (either.isLeft()) {
        throw new AtlasBaseException(DISCOVERY_QUERY_FAILED, query);
    }
    Expression expression = either.right().get();
    Expression validExpression = QueryProcessor.validate(expression);
    GremlinQuery gremlinQuery = new GremlinTranslator(validExpression, graphPersistenceStrategy).translate();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Translated Gremlin Query: {}", gremlinQuery.queryStr());
    }
    return gremlinQuery;
}
Also used : GremlinTranslator(org.apache.atlas.query.GremlinTranslator) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AliasExpression(org.apache.atlas.query.Expressions.AliasExpression) Expression(org.apache.atlas.query.Expressions.Expression) SelectExpression(org.apache.atlas.query.Expressions.SelectExpression) NoSuccess(scala.util.parsing.combinator.Parsers.NoSuccess) QueryParams(org.apache.atlas.query.QueryParams) GremlinQuery(org.apache.atlas.query.GremlinQuery) AtlasGremlinQuery(org.apache.atlas.util.AtlasGremlinQueryProvider.AtlasGremlinQuery)

Aggregations

AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)1 AliasExpression (org.apache.atlas.query.Expressions.AliasExpression)1 Expression (org.apache.atlas.query.Expressions.Expression)1 SelectExpression (org.apache.atlas.query.Expressions.SelectExpression)1 GremlinQuery (org.apache.atlas.query.GremlinQuery)1 GremlinTranslator (org.apache.atlas.query.GremlinTranslator)1 QueryParams (org.apache.atlas.query.QueryParams)1 AtlasGremlinQuery (org.apache.atlas.util.AtlasGremlinQueryProvider.AtlasGremlinQuery)1 NoSuccess (scala.util.parsing.combinator.Parsers.NoSuccess)1