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

The following examples show how to use org.apache.atlas.model.discovery.SearchParameters#setClassification() . 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: UserProfileServiceTest.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = { "addAdditionalSearchesForUser"})
public void updateSearch() throws AtlasBaseException {
    String               userName  = getIndexBasedUserName(0);
    String               queryName = getIndexBasedQueryName(0);
    AtlasUserSavedSearch expected  = userProfileService.getSavedSearch(userName, queryName);

    assertNotNull(expected);

    SearchParameters sp = expected.getSearchParameters();

    sp.setClassification("new-classification");

    AtlasUserSavedSearch actual = userProfileService.updateSavedSearch(expected);

    assertNotNull(actual);
    assertNotNull(actual.getSearchParameters());
    assertEquals(actual.getSearchParameters().getClassification(), expected.getSearchParameters().getClassification());
}
 
Example 2
Source File: TestEntitiesREST.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = "testSearchByMultiTags")
public void testSearchByTerms() throws Exception {

    // database - phi, felt_classification
    // table1 - phi, classification, term: term1 | table2 - classification, term:term2
    // column - phi
    assignTermTo(term1, tableEntity);
    assignTermTo(term1, tableEntity2);

    searchParameters = new SearchParameters();
    searchParameters.setTermName(term1.getName() + "@testSearchGlossary");
    searchParameters.setClassification(CLASSIFICATION);

    AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 2);

    searchParameters.setClassification(PII);
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNull(res.getEntities());

    searchParameters.setClassification(PHI);
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 1);
}
 
Example 3
Source File: EntitySearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = AtlasBaseException.class, expectedExceptionsMessageRegExp = "NotExisting: Unknown/invalid classification")
public void searchByNonExistingClassification() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("hive_process");
    params.setClassification("NotExisting");
    params.setLimit(10);

    SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet());
    new EntitySearchProcessor(context);
}
 
Example 4
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchByTagAndTagFilters() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setClassification(DIMENSIONAL_CLASSIFICATION);
    FilterCriteria filterCriteria = getSingleFilterCondition("attr1", Operator.EQ, "Test");
    params.setTagFilters(filterCriteria);

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

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

}
 
Example 5
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchByTag() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setClassification(DIMENSION_CLASSIFICATION);

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

    assertEquals(entityHeaders.size(), dimensionTagEntities);
}
 
Example 6
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchByTagAndIndexSysFilters() throws AtlasBaseException {

    SearchParameters params = new SearchParameters();
    params.setClassification(DIMENSION_CLASSIFICATION);
    FilterCriteria filterCriteria = getSingleFilterCondition("__timestamp", Operator.LT, String.valueOf(System.currentTimeMillis()));
    params.setTagFilters(filterCriteria);

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

    assertEquals(entityHeaders.size(), dimensionTagEntities);
}
 
Example 7
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchByALLTagAndIndexSysFilters() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setClassification(ALL_CLASSIFICATION_TYPES);
    FilterCriteria filterCriteria = getSingleFilterCondition("__timestamp", Operator.LT, String.valueOf(System.currentTimeMillis()));
    params.setTagFilters(filterCriteria);

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

    assertEquals(entityHeaders.size(), totalClassifiedEntities);
}
 
Example 8
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();
}
 
Example 9
Source File: EntitySearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchWithEntityTypesAndEntityFiltersAndTag() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName(DATABASE_TYPE+","+HIVE_TABLE_TYPE);
    SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("owner", SearchParameters.Operator.CONTAINS, "ETL");
    params.setEntityFilters(filterCriteria);
    params.setClassification(LOGDATA_CLASSIFICATION);
    params.setLimit(20);

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

    EntitySearchProcessor processor = new EntitySearchProcessor(context);
    assertEquals(processor.execute().size(), 2);
}
 
Example 10
Source File: UserProfileServiceTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
private SearchParameters getActualSearchParameters() {
    SearchParameters sp = new SearchParameters();

    sp.setClassification("test-classification");
    sp.setQuery("g.v().has('__guid').__guid.toList()");
    sp.setLimit(10);
    sp.setTypeName("some-type");

    return sp;
}
 
Example 11
Source File: EntitySearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void ALLEntityTypeWithTag() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName(SearchParameters.ALL_ENTITY_TYPES);
    params.setClassification(FACT_CLASSIFICATION);
    params.setLimit(20);

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

    EntitySearchProcessor processor = new EntitySearchProcessor(context);
    assertEquals(processor.execute().size(), 5);
}
 
Example 12
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 13
Source File: EntitySearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void emptySearchByClassification() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("hive_table");
    params.setClassification("PII");
    params.setLimit(10);

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

    EntitySearchProcessor processor = new EntitySearchProcessor(context);

    assertEquals(processor.getResultCount(), 0);
    assertEquals(processor.execute().size(), 0);
}
 
Example 14
Source File: EntitySearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchByClassificationSortBy() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("hive_table");
    params.setClassification("Metric");
    params.setLimit(10);
    params.setSortBy("createTime");
    params.setSortOrder(SortOrder.ASCENDING);

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

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

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


    AtlasVertex firstVertex = vertices.get(0);

    Date firstDate = (Date) entityRetriever.toAtlasEntityHeader(firstVertex, Sets.newHashSet(params.getSortBy())).getAttribute(params.getSortBy());

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

    assertTrue(firstDate.before(secondDate));
}
 
Example 15
Source File: EntitySearchProcessorTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void searchTablesByClassification() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setTypeName("hive_column");
    params.setClassification("PII");
    params.setLimit(10);

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

    EntitySearchProcessor processor = new EntitySearchProcessor(context);

    assertEquals(processor.getResultCount(), 4);
    assertEquals(processor.execute().size(), 4);
}
 
Example 16
Source File: TestEntitiesREST.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testSearchBySystemAttributesWithQuery")
public void testTagSearchBySystemAttributes() throws Exception {

    // database - phi, felt_classification
    // table1 - phi, classification, table2 - classification,
    // col - phi
    searchParameters = new SearchParameters();
    searchParameters.setClassification("_ALL_CLASSIFICATION_TYPES");
    SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria();
    SearchParameters.FilterCriteria subFc1 = new SearchParameters.FilterCriteria();
    SearchParameters.FilterCriteria subFc2 = new SearchParameters.FilterCriteria();

    subFc1.setAttributeName(TIMESTAMP_PROPERTY_KEY);
    subFc1.setOperator(SearchParameters.Operator.LT);
    subFc1.setAttributeValue(String.valueOf(System.currentTimeMillis()));

    subFc2.setAttributeName(STATE_PROPERTY_KEY);
    subFc2.setOperator(SearchParameters.Operator.EQ);
    subFc2.setAttributeValue("ACTIVE");

    fc.setCriterion(Arrays.asList(subFc1, subFc2));
    fc.setCondition(AND);

    searchParameters.setTagFilters(fc);

    AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters);

    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 7);
}
 
Example 17
Source File: TestEntitiesREST.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testSearchByOtherSystemAttributes")
public void testBasicSearchWithFilter() throws Exception {

    // database - phi, felt_classification
    // table1 - phi, classification, table2 - classification,
    // col - phi
    searchParameters = new SearchParameters();
    searchParameters.setIncludeSubClassifications(false);
    searchParameters.setClassification(TestUtilsV2.CLASSIFICATION);

    SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria();
    fc.setOperator(SearchParameters.Operator.CONTAINS);
    fc.setAttributeValue("new comments");
    fc.setAttributeName("tag");

    searchParameters.setTagFilters(fc);

    AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNull(res.getEntities());

    fc.setOperator(SearchParameters.Operator.ENDS_WITH);
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNull(res.getEntities());

    fc.setOperator(SearchParameters.Operator.STARTS_WITH);
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNull(res.getEntities());
}
 
Example 18
Source File: TestEntitiesREST.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testWildCardBasicSearch() throws Exception {

    //table - classification
    searchParameters = new SearchParameters();

    searchParameters.setClassification("*");
    AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 2);

    searchParameters.setClassification("_CLASSIFIED");
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 2);

    // Test wildcard usage of basic search
    searchParameters.setClassification("cl*");
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 2);

    searchParameters.setClassification("*ion");
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 2);

    searchParameters.setClassification("*l*");
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 2);

    searchParameters.setClassification("_NOT_CLASSIFIED");
    searchParameters.setTypeName(DATABASE_TYPE);
    res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 1);
}
 
Example 19
Source File: TestEntitiesREST.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = "testBasicSearchWithSubTypes")
public void testGraphQueryFilter() throws Exception {

    // table - classification
    // database - fetl_classification
    // column - phi
    searchParameters = new SearchParameters();
    searchParameters.setQuery("sample_string");
    searchParameters.setClassification(PHI);

    SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria();
    fc.setOperator(SearchParameters.Operator.EQ);
    fc.setAttributeName("booleanAttr");
    fc.setAttributeValue("true");

    searchParameters.setTagFilters(fc);
    AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters);
    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 2);
    Assert.assertEquals(res.getEntities().get(0).getTypeName(), COLUMN_TYPE);

    AtlasClassification cls = new AtlasClassification(TestUtilsV2.PHI, new HashMap<String, Object>() {{
        put("stringAttr", "sample_string");
        put("booleanAttr", false);
        put("integerAttr", 100);
    }});

    ClassificationAssociateRequest clsAssRequest = new ClassificationAssociateRequest(Collections.singletonList(createdGuids.get(TABLE_TYPE).get(0)), cls);
    entityREST.addClassification(clsAssRequest);

    final AtlasClassification result_tag = entityREST.getClassification(createdGuids.get(TABLE_TYPE).get(0), TestUtilsV2.PHI);
    Assert.assertNotNull(result_tag);
    Assert.assertEquals(result_tag.getTypeName(), PHI);

    // table - phi, classification
    // database - fetl_classification
    // column - phi
    fc.setAttributeValue("false");
    res = discoveryREST.searchWithParameters(searchParameters);

    Assert.assertNotNull(res.getEntities());
    Assert.assertEquals(res.getEntities().size(), 1);
    Assert.assertEquals(res.getEntities().get(0).getTypeName(), TABLE_TYPE);
}
 
Example 20
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 3 votes vote down vote up
@Test
public void searchByWildcardTag() throws AtlasBaseException {
    SearchParameters params = new SearchParameters();
    params.setClassification("Dimension*");

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

    assertEquals(entityHeaders.size(), dimensionTagEntities + 1);

}