use of org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult in project incubator-atlas by apache.
the class QuickStartV2 method search.
private void search() throws Exception {
System.out.println("\nSample DSL Queries: ");
for (String dslQuery : getDSLQueries()) {
AtlasSearchResult results = atlasClientV2.dslSearchWithParams(dslQuery, 10, 0);
if (results != null) {
List<AtlasEntityHeader> entitiesResult = results.getEntities();
List<AtlasFullTextResult> fullTextResults = results.getFullTextResult();
AttributeSearchResult attribResult = results.getAttributes();
if (CollectionUtils.isNotEmpty(entitiesResult)) {
System.out.println("query [" + dslQuery + "] returned [" + entitiesResult.size() + "] rows.");
} else if (CollectionUtils.isNotEmpty(fullTextResults)) {
System.out.println("query [" + dslQuery + "] returned [" + fullTextResults.size() + "] rows.");
} else if (attribResult != null) {
System.out.println("query [" + dslQuery + "] returned [" + attribResult.getValues().size() + "] rows.");
}
} else {
System.out.println("query [" + dslQuery + "] failed, results:" + results);
}
}
}
use of org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult in project incubator-atlas by apache.
the class EntityDiscoveryService method toAttributesResult.
private AttributeSearchResult toAttributesResult(List list, GremlinQuery query) {
AttributeSearchResult ret = new AttributeSearchResult();
List<String> names = new ArrayList<>();
List<List<Object>> values = new ArrayList<>();
// extract select attributes from gremlin query
Option<SelectExpression> selectExpr = SelectExpressionHelper.extractSelectExpression(query.expr());
if (selectExpr.isDefined()) {
List<AliasExpression> aliases = selectExpr.get().toJavaList();
if (CollectionUtils.isNotEmpty(aliases)) {
for (AliasExpression alias : aliases) {
names.add(alias.alias());
}
ret.setName(names);
}
}
for (Object mapObj : list) {
Map map = (mapObj instanceof Map ? (Map) mapObj : null);
if (MapUtils.isNotEmpty(map)) {
for (Object key : map.keySet()) {
Object vals = map.get(key);
values.add((List<Object>) vals);
}
ret.setValues(values);
}
}
return ret;
}
Aggregations