use of org.apache.atlas.model.instance.AtlasEntityHeader in project incubator-atlas by apache.
the class AtlasEntityChangeNotifier method doFullTextMapping.
private void doFullTextMapping(List<AtlasEntityHeader> atlasEntityHeaders) {
if (CollectionUtils.isEmpty(atlasEntityHeaders)) {
return;
}
try {
if (!AtlasRepositoryConfiguration.isFullTextSearchEnabled()) {
return;
}
} catch (AtlasException e) {
LOG.warn("Unable to determine if FullText is disabled. Proceeding with FullText mapping");
}
for (AtlasEntityHeader atlasEntityHeader : atlasEntityHeaders) {
String guid = atlasEntityHeader.getGuid();
AtlasVertex atlasVertex = AtlasGraphUtilsV1.findByGuid(guid);
if (atlasVertex == null) {
continue;
}
try {
String fullText = fullTextMapperV2.getIndexTextForEntity(guid);
GraphHelper.setProperty(atlasVertex, Constants.ENTITY_TEXT_PROPERTY_KEY, fullText);
} catch (AtlasBaseException e) {
LOG.error("FullText mapping failed for Vertex[ guid = {} ]", guid, e);
}
}
}
use of org.apache.atlas.model.instance.AtlasEntityHeader in project incubator-atlas by apache.
the class AtlasEntityChangeNotifier method doFullTextMapping.
private void doFullTextMapping(String guid) {
AtlasEntityHeader entityHeader = new AtlasEntityHeader();
entityHeader.setGuid(guid);
doFullTextMapping(Collections.singletonList(entityHeader));
}
use of org.apache.atlas.model.instance.AtlasEntityHeader in project incubator-atlas by apache.
the class QuickStartV2IT method testLineageIsMaintained.
@Test
public void testLineageIsMaintained() throws AtlasServiceException, JSONException {
String salesFactTableId = getTableId(QuickStartV2.SALES_FACT_TABLE);
String timeDimTableId = getTableId(QuickStartV2.TIME_DIM_TABLE);
String salesFactDailyMVId = getTableId(QuickStartV2.SALES_FACT_DAILY_MV_TABLE);
String salesFactMonthlyMvId = getTableId(QuickStartV2.SALES_FACT_MONTHLY_MV_TABLE);
String salesDailyProcessId = getProcessId(QuickStartV2.LOAD_SALES_DAILY_PROCESS);
String salesMonthlyProcessId = getProcessId(QuickStartV2.LOAD_SALES_MONTHLY_PROCESS);
AtlasLineageInfo inputLineage = atlasClientV2.getLineageInfo(salesFactDailyMVId, LineageDirection.BOTH, 0);
List<LineageRelation> relations = new ArrayList<>(inputLineage.getRelations());
Map<String, AtlasEntityHeader> entityMap = inputLineage.getGuidEntityMap();
assertEquals(relations.size(), 5);
assertEquals(entityMap.size(), 6);
assertTrue(entityMap.containsKey(salesFactTableId));
assertTrue(entityMap.containsKey(timeDimTableId));
assertTrue(entityMap.containsKey(salesFactDailyMVId));
assertTrue(entityMap.containsKey(salesDailyProcessId));
assertTrue(entityMap.containsKey(salesFactMonthlyMvId));
assertTrue(entityMap.containsKey(salesMonthlyProcessId));
}
use of org.apache.atlas.model.instance.AtlasEntityHeader in project incubator-atlas by apache.
the class TestEntitiesREST method testUpdateWithSerializedEntities.
@Test
public void testUpdateWithSerializedEntities() throws Exception {
//Check with serialization and deserialization of entity attributes for the case
// where attributes which are de-serialized into a map
AtlasEntity dbEntity = TestUtilsV2.createDBEntity();
AtlasEntity tableEntity = TestUtilsV2.createTableEntity(dbEntity);
final AtlasEntity colEntity = TestUtilsV2.createColumnEntity(tableEntity);
List<AtlasEntity> columns = new ArrayList<AtlasEntity>() {
{
add(colEntity);
}
};
tableEntity.setAttribute("columns", getObjIdList(columns));
AtlasEntity newDBEntity = serDeserEntity(dbEntity);
AtlasEntity newTableEntity = serDeserEntity(tableEntity);
AtlasEntitiesWithExtInfo newEntities = new AtlasEntitiesWithExtInfo();
newEntities.addEntity(newDBEntity);
newEntities.addEntity(newTableEntity);
for (AtlasEntity column : columns) {
newEntities.addReferredEntity(serDeserEntity(column));
}
EntityMutationResponse response2 = entityREST.createOrUpdate(newEntities);
List<AtlasEntityHeader> newGuids = response2.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE);
Assert.assertNotNull(newGuids);
Assert.assertEquals(newGuids.size(), 3);
}
use of org.apache.atlas.model.instance.AtlasEntityHeader in project incubator-atlas by apache.
the class EntityLineageServiceTest method testNewLineageWithDelete.
@Test
public void testNewLineageWithDelete() throws Exception {
TestUtils.skipForGremlin3EnabledGraphDb();
String tableName = "table" + random();
createTable(tableName, 3, true);
String entityGuid = getEntityId(HIVE_TABLE_TYPE, "name", tableName);
AtlasLineageInfo inputLineage = getInputLineageInfo(entityGuid, 5);
assertNotNull(inputLineage);
System.out.println("input lineage = " + inputLineage);
Map<String, AtlasEntityHeader> entitiesInput = inputLineage.getGuidEntityMap();
assertNotNull(entitiesInput);
assertEquals(entitiesInput.size(), 3);
Set<LineageRelation> relationsInput = inputLineage.getRelations();
assertNotNull(relationsInput);
assertEquals(relationsInput.size(), 2);
AtlasEntityHeader tableEntityInput = entitiesInput.get(entityGuid);
assertEquals(tableEntityInput.getStatus(), Status.ACTIVE);
AtlasLineageInfo outputLineage = getOutputLineageInfo(entityGuid, 5);
assertNotNull(outputLineage);
System.out.println("output lineage = " + outputLineage);
Map<String, AtlasEntityHeader> entitiesOutput = outputLineage.getGuidEntityMap();
assertNotNull(entitiesOutput);
assertEquals(entitiesOutput.size(), 3);
Set<LineageRelation> relationsOutput = outputLineage.getRelations();
assertNotNull(relationsOutput);
assertEquals(relationsOutput.size(), 2);
AtlasEntityHeader tableEntityOutput = entitiesOutput.get(entityGuid);
assertEquals(tableEntityOutput.getStatus(), Status.ACTIVE);
AtlasLineageInfo bothLineage = getBothLineageInfo(entityGuid, 5);
assertNotNull(bothLineage);
System.out.println("both lineage = " + bothLineage);
Map<String, AtlasEntityHeader> entitiesBoth = bothLineage.getGuidEntityMap();
assertNotNull(entitiesBoth);
assertEquals(entitiesBoth.size(), 5);
Set<LineageRelation> relationsBoth = bothLineage.getRelations();
assertNotNull(relationsBoth);
assertEquals(relationsBoth.size(), 4);
AtlasEntityHeader tableEntityBoth = entitiesBoth.get(entityGuid);
assertEquals(tableEntityBoth.getStatus(), Status.ACTIVE);
//Delete the table entity. Lineage for entity returns the same results as before.
//Lineage for table name throws EntityNotFoundException
EntityResult deleteResult = repository.deleteEntities(Arrays.asList(entityGuid));
assertTrue(deleteResult.getDeletedEntities().contains(entityGuid));
inputLineage = getInputLineageInfo(entityGuid, 5);
tableEntityInput = inputLineage.getGuidEntityMap().get(entityGuid);
assertEquals(tableEntityInput.getStatus(), Status.DELETED);
assertEquals(inputLineage.getGuidEntityMap().size(), 3);
outputLineage = getOutputLineageInfo(entityGuid, 5);
tableEntityOutput = outputLineage.getGuidEntityMap().get(entityGuid);
assertEquals(tableEntityOutput.getStatus(), Status.DELETED);
assertEquals(outputLineage.getGuidEntityMap().size(), 3);
bothLineage = getBothLineageInfo(entityGuid, 5);
tableEntityBoth = bothLineage.getGuidEntityMap().get(entityGuid);
assertEquals(tableEntityBoth.getStatus(), Status.DELETED);
assertEquals(bothLineage.getGuidEntityMap().size(), 5);
}
Aggregations