Java Code Examples for org.apache.atlas.model.discovery.SearchParameters#setExcludeDeletedEntities()

The following examples show how to use org.apache.atlas.model.discovery.SearchParameters#setExcludeDeletedEntities() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableReplicationRequestProcessor.java    From atlas with Apache License 2.0 5 votes vote down vote up
private SearchParameters getSearchParameters(String dbName, String sourceCluster) {
    String query = String.format(QUERY_DB_NAME_EQUALS, dbName);

    SearchParameters parameters = new SearchParameters();
    parameters.setExcludeDeletedEntities(false);
    parameters.setTypeName(TYPE_HIVE_TABLE);
    parameters.setExcludeDeletedEntities(true);

    parameters.setAttributes(new HashSet<String>() {{ add(AtlasImportRequest.OPTION_KEY_REPLICATED_FROM); }});
    parameters.setQuery(query);

    return parameters;
}
 
Example 2
Source File: FreeTextSearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchTablesByName() throws AtlasBaseException, InterruptedException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("hive_table");
    params.setQuery("sales");
    params.setExcludeDeletedEntities(true);
    params.setLimit(3);

    SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet());

    FreeTextSearchProcessor processor = new FreeTextSearchProcessor(context);

    assertEquals(processor.getResultCount(), 3);
    assertEquals(processor.execute().size(), 3);
}
 
Example 3
Source File: FreeTextSearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchByNameSortBy() throws AtlasBaseException, InterruptedException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("hive_table");
    params.setQuery("sales");
    params.setExcludeDeletedEntities(true);
    params.setLimit(3);
    params.setSortBy("owner");
    params.setSortOrder(SortOrder.ASCENDING);

    SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet());

    FreeTextSearchProcessor processor = new FreeTextSearchProcessor(context);

    List<AtlasVertex> vertices = processor.execute();

    assertEquals(processor.getResultCount(), 3);
    assertEquals(vertices.size(), 3);

    AtlasVertex firstVertex = vertices.get(0);

    String firstOwner = (String) entityRetriever.toAtlasEntityHeader(firstVertex, Sets.newHashSet(params.getSortBy())).getAttribute(params.getSortBy());

    AtlasVertex secondVertex = vertices.get(1);
    String secondOwner = (String) entityRetriever.toAtlasEntityHeader(secondVertex, Sets.newHashSet(params.getSortBy())).getAttribute(params.getSortBy());

    assertEquals(firstOwner, "Jane BI");
    assertEquals(secondOwner, "Joe");
}
 
Example 4
Source File: FreeTextSearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void emptySearch() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("hive_table");
    params.setQuery("not_exists");
    params.setExcludeDeletedEntities(true);
    params.setLimit(3);

    SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet());

    FreeTextSearchProcessor processor = new FreeTextSearchProcessor(context);

    assertEquals(processor.getResultCount(), 0);
    assertEquals(processor.execute().size(), 0);
}
 
Example 5
Source File: FreeTextSearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = AtlasBaseException.class, expectedExceptionsMessageRegExp = "not_exists_type: Unknown/invalid typename")
public void searchByNonExistingClassification() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("not_exists_type");
    params.setQuery("aaa");
    params.setExcludeDeletedEntities(true);
    params.setLimit(3);

    SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet());
    new FreeTextSearchProcessor(context);
}
 
Example 6
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
public void searchByTagAndGraphSysFilters() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setClassification(DIMENSION_CLASSIFICATION);
    FilterCriteria filterCriteria = getSingleFilterCondition("__entityStatus", Operator.EQ, "DELETED");
    params.setTagFilters(filterCriteria);
    params.setExcludeDeletedEntities(false);

    List<AtlasEntityHeader> entityHeaders = discoveryService.searchWithParameters(params).getEntities();

    assertEquals(entityHeaders.size(), 1);
    assertEquals(entityHeaders.get(0).getGuid(), dimensionTagDeleteGuid);

}
 
Example 7
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
private int getEntityWithTagCountHistorical() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setClassification(ALL_CLASSIFICATION_TYPES);
    params.setExcludeDeletedEntities(false);

    List<AtlasEntityHeader> entityHeaders = discoveryService.searchWithParameters(params).getEntities();
    return entityHeaders.size();
}