Search in sources :

Example 16 with AtlasEntityHeader

use of org.apache.atlas.model.instance.AtlasEntityHeader 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);
        }
    }
}
Also used : AttributeSearchResult(org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) AtlasFullTextResult(org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult) AtlasSearchResult(org.apache.atlas.model.discovery.AtlasSearchResult)

Example 17 with AtlasEntityHeader

use of org.apache.atlas.model.instance.AtlasEntityHeader in project incubator-atlas by apache.

the class QuickStartV2 method createInstance.

private AtlasEntity createInstance(AtlasEntity entity, String[] traitNames) throws Exception {
    AtlasEntity ret = null;
    EntityMutationResponse response = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(entity));
    List<AtlasEntityHeader> entities = response.getEntitiesByOperation(EntityOperation.CREATE);
    if (CollectionUtils.isNotEmpty(entities)) {
        AtlasEntityWithExtInfo getByGuidResponse = atlasClientV2.getEntityByGuid(entities.get(0).getGuid());
        ret = getByGuidResponse.getEntity();
        System.out.println("Created entity of type [" + ret.getTypeName() + "], guid: " + ret.getGuid());
    }
    return ret;
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader)

Example 18 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 19 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 20 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)

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