Search in sources :

Example 1 with AtlasEntityHeader

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);
        }
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) AtlasException(org.apache.atlas.AtlasException)

Example 2 with AtlasEntityHeader

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));
}
Also used : AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader)

Example 3 with AtlasEntityHeader

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));
}
Also used : AtlasLineageInfo(org.apache.atlas.model.lineage.AtlasLineageInfo) LineageRelation(org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation) ArrayList(java.util.ArrayList) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) Test(org.testng.annotations.Test)

Example 4 with AtlasEntityHeader

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);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) ArrayList(java.util.ArrayList) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) Test(org.testng.annotations.Test)

Example 5 with AtlasEntityHeader

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);
}
Also used : AtlasLineageInfo(org.apache.atlas.model.lineage.AtlasLineageInfo) LineageRelation(org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) EntityResult(org.apache.atlas.model.legacy.EntityResult) Test(org.testng.annotations.Test) BaseRepositoryTest(org.apache.atlas.BaseRepositoryTest)

Aggregations

AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)65 Test (org.testng.annotations.Test)46 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)38 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)34 BeforeTest (org.testng.annotations.BeforeTest)22 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)15 ArrayList (java.util.ArrayList)14 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)14 HashMap (java.util.HashMap)12 AtlasLineageInfo (org.apache.atlas.model.lineage.AtlasLineageInfo)12 List (java.util.List)10 Map (java.util.Map)8 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)8 LineageRelation (org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation)8 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)8 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)8 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)7 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)6 BaseRepositoryTest (org.apache.atlas.BaseRepositoryTest)5 TestUtils.randomString (org.apache.atlas.TestUtils.randomString)5