use of org.apache.atlas.model.lineage.AtlasLineageInfo in project incubator-atlas by apache.
the class QuickStartV2 method lineage.
private void lineage() throws AtlasServiceException {
System.out.println("\nSample Lineage Info: ");
AtlasLineageInfo lineageInfo = atlasClientV2.getLineageInfo(getTableId(SALES_FACT_DAILY_MV_TABLE), LineageDirection.BOTH, 0);
Set<LineageRelation> relations = lineageInfo.getRelations();
Map<String, AtlasEntityHeader> guidEntityMap = lineageInfo.getGuidEntityMap();
for (LineageRelation relation : relations) {
AtlasEntityHeader fromEntity = guidEntityMap.get(relation.getFromEntityId());
AtlasEntityHeader toEntity = guidEntityMap.get(relation.getToEntityId());
System.out.println(fromEntity.getDisplayText() + "(" + fromEntity.getTypeName() + ") -> " + toEntity.getDisplayText() + "(" + toEntity.getTypeName() + ")");
}
}
use of org.apache.atlas.model.lineage.AtlasLineageInfo in project incubator-atlas by apache.
the class EntityLineageService method getLineageInfo.
private AtlasLineageInfo getLineageInfo(String guid, LineageDirection direction, int depth) throws AtlasBaseException {
Map<String, AtlasEntityHeader> entities = new HashMap<>();
Set<LineageRelation> relations = new HashSet<>();
String lineageQuery = getLineageQuery(guid, direction, depth);
List paths = (List) graph.executeGremlinScript(lineageQuery, true);
if (CollectionUtils.isNotEmpty(paths)) {
for (Object path : paths) {
if (path instanceof List) {
List vertices = (List) path;
if (CollectionUtils.isNotEmpty(vertices)) {
AtlasEntityHeader prev = null;
for (Object vertex : vertices) {
if (!(vertex instanceof AtlasVertex)) {
continue;
}
AtlasEntityHeader entity = entityRetriever.toAtlasEntityHeader((AtlasVertex) vertex);
if (!entities.containsKey(entity.getGuid())) {
entities.put(entity.getGuid(), entity);
}
if (prev != null) {
if (direction.equals(LineageDirection.INPUT)) {
relations.add(new LineageRelation(entity.getGuid(), prev.getGuid()));
} else if (direction.equals(LineageDirection.OUTPUT)) {
relations.add(new LineageRelation(prev.getGuid(), entity.getGuid()));
}
}
prev = entity;
}
}
}
}
}
return new AtlasLineageInfo(guid, entities, relations, direction, depth);
}
Aggregations