Java Code Examples for org.apache.atlas.model.discovery.SearchParameters#setEntityFilters()
The following examples show how to use
org.apache.atlas.model.discovery.SearchParameters#setEntityFilters() .
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: TestEntitiesREST.java From atlas with Apache License 2.0 | 6 votes |
@Test public void testSearchByMultiSystemAttributes() throws Exception { searchParameters = new SearchParameters(); searchParameters.setTypeName("_ALL_ENTITY_TYPES"); SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria(); SearchParameters.FilterCriteria subFc1 = new SearchParameters.FilterCriteria(); SearchParameters.FilterCriteria subFc2 = new SearchParameters.FilterCriteria(); subFc1.setAttributeName(MODIFICATION_TIMESTAMP_PROPERTY_KEY); subFc1.setOperator(SearchParameters.Operator.LT); subFc1.setAttributeValue(String.valueOf(System.currentTimeMillis())); subFc2.setAttributeName(TIMESTAMP_PROPERTY_KEY); subFc2.setOperator(SearchParameters.Operator.LT); subFc2.setAttributeValue(String.valueOf(System.currentTimeMillis())); fc.setCriterion(Arrays.asList(subFc1, subFc2)); fc.setCondition(AND); searchParameters.setEntityFilters(fc); AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertTrue(res.getEntities().size() > 5); }
Example 2
Source File: AtlasAuditService.java From atlas with Apache License 2.0 | 6 votes |
private SearchParameters getSearchParameters(AuditSearchParameters auditSearchParameters) throws AtlasBaseException { SearchParameters searchParameters = new SearchParameters(); searchParameters.setTypeName(ENTITY_TYPE_AUDIT_ENTRY); SearchParameters.FilterCriteria validFilter = getNonEmptyFilter(auditSearchParameters.getAuditFilters()); searchParameters.setEntityFilters(validFilter); searchParameters.setLimit(auditSearchParameters.getLimit()); searchParameters.setOffset(auditSearchParameters.getOffset()); String sortBy = auditSearchParameters.getSortBy(); validateSortByParameter(sortBy); searchParameters.setSortBy(auditSearchParameters.getSortBy()); searchParameters.setSortOrder(auditSearchParameters.getSortOrder()); return searchParameters; }
Example 3
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(priority = -1) public void searchWithNEQ_stringAttr() throws AtlasBaseException { String expectedEntityName = "hive_Table_Null_tableType"; createDummyEntity(expectedEntityName,HIVE_TABLE_TYPE); SearchParameters params = new SearchParameters(); params.setTypeName(HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("tableType", SearchParameters.Operator.NEQ, "Managed"); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, indexer.getVertexIndexKeys()); EntitySearchProcessor processor = new EntitySearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(vertices.size(), 3); List<String> nameList = new ArrayList<>(); for (AtlasVertex vertex : vertices) { nameList.add((String) entityRetriever.toAtlasEntityHeader(vertex, Collections.singleton("name")).getAttribute("name")); } assertTrue(nameList.contains(expectedEntityName)); }
Example 4
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(dependsOnMethods = "searchWithNEQ_stringAttr") public void searchWithNEQ_pipeSeperatedAttr() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("__classificationNames", SearchParameters.Operator.NEQ, METRIC_CLASSIFICATION); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, indexer.getVertexIndexKeys()); EntitySearchProcessor processor = new EntitySearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(vertices.size(), 7); List<String> nameList = new ArrayList<>(); for (AtlasVertex vertex : vertices) { nameList.add((String) entityRetriever.toAtlasEntityHeader(vertex, Collections.singleton("name")).getAttribute("name")); } assertTrue(nameList.contains("hive_Table_Null_tableType")); }
Example 5
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(dependsOnMethods = "searchWithNEQ_stringAttr") public void searchWithNEQ_doubleAttr() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("retention", SearchParameters.Operator.NEQ, "5"); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, indexer.getVertexIndexKeys()); EntitySearchProcessor processor = new EntitySearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(vertices.size(), 1); List<String> nameList = new ArrayList<>(); for (AtlasVertex vertex : vertices) { nameList.add((String) entityRetriever.toAtlasEntityHeader(vertex, Collections.singleton("name")).getAttribute("name")); } assertTrue(nameList.contains("hive_Table_Null_tableType")); }
Example 6
Source File: TestEntitiesREST.java From atlas with Apache License 2.0 | 5 votes |
@Test(dependsOnMethods = "testGraphQueryFilter") public void testSearchByMultiTags() throws Exception { addTagTo(PHI, DATABASE_TYPE); // database - phi, felt_classification // table1 - phi, classification, table2 - classification, // column - phi searchParameters = new SearchParameters(); searchParameters.setIncludeSubClassifications(false); searchParameters.setTypeName("_ALL_ENTITY_TYPES"); SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria(); SearchParameters.FilterCriteria subFc1 = new SearchParameters.FilterCriteria(); SearchParameters.FilterCriteria subFc2 = new SearchParameters.FilterCriteria(); subFc1.setAttributeName(CLASSIFICATION_NAMES_KEY); subFc1.setOperator(SearchParameters.Operator.CONTAINS); subFc1.setAttributeValue(PHI); subFc2.setAttributeName(CLASSIFICATION_NAMES_KEY); subFc2.setOperator(SearchParameters.Operator.CONTAINS); subFc2.setAttributeValue(CLASSIFICATION); fc.setCriterion(Arrays.asList(subFc1, subFc2)); fc.setCondition(AND); searchParameters.setEntityFilters(fc); AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertEquals(res.getEntities().size(), 2); subFc2.setAttributeValue(FETL_CLASSIFICATION); res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertEquals(res.getEntities().size(), 1); }
Example 7
Source File: TestEntitiesREST.java From atlas with Apache License 2.0 | 5 votes |
@Test(dependsOnMethods = "testSearchByMultiTags") public void testSearchByOtherSystemAttributes() throws Exception { // database - phi, felt_classification // table1 - phi, classification, table2 - classification, // col1 - phi, col2 - phi searchParameters = new SearchParameters(); searchParameters.setTypeName("_ALL_ENTITY_TYPES"); SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria(); fc.setAttributeName(CLASSIFICATION_NAMES_KEY); fc.setOperator(SearchParameters.Operator.EQ); fc.setAttributeValue(CLASSIFICATION); searchParameters.setEntityFilters(fc); AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertEquals(res.getEntities().size(), 2); fc.setOperator(SearchParameters.Operator.CONTAINS); fc.setAttributeValue("cla"); res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertEquals(res.getEntities().size(), 3); fc.setOperator(SearchParameters.Operator.CONTAINS); fc.setAttributeValue(PHI); res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertEquals(res.getEntities().size(), 4); }
Example 8
Source File: ExportImportAuditService.java From atlas with Apache License 2.0 | 5 votes |
private SearchParameters getSearchParameters(int limit, int offset, SearchParameters.FilterCriteria criteria) { SearchParameters searchParameters = new SearchParameters(); searchParameters.setTypeName(ENTITY_TYPE_NAME); searchParameters.setEntityFilters(criteria); searchParameters.setLimit(limit); searchParameters.setOffset(offset); return searchParameters; }
Example 9
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = AtlasBaseException.class, expectedExceptionsMessageRegExp = "Attribute tableType not found for type "+DATABASE_TYPE) public void entityFiltersNotAllowed() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE+","+HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("tableType", SearchParameters.Operator.CONTAINS, "ETL"); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); }
Example 10
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchWithEntityTypesAndEntityFilters() 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.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 4); }
Example 11
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@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 12
Source File: TestEntitiesREST.java From atlas with Apache License 2.0 | 3 votes |
@Test public void testCustomAttributesSearch() throws Exception { AtlasEntity dbWithCustomAttr = new AtlasEntity(dbEntity); Map customAttr = new HashMap<String, String>() {{ put("key1", "value1"); }}; dbWithCustomAttr.setCustomAttributes(customAttr); AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo(dbWithCustomAttr); EntityMutationResponse response = entityREST.createOrUpdate(atlasEntitiesWithExtInfo); Assert.assertNotNull(response.getUpdatedEntitiesByTypeName(DATABASE_TYPE)); searchParameters = new SearchParameters(); searchParameters.setTypeName("_ALL_ENTITY_TYPES"); SearchParameters.FilterCriteria filter = new SearchParameters.FilterCriteria(); filter.setAttributeName(CUSTOM_ATTRIBUTES_PROPERTY_KEY); filter.setOperator(SearchParameters.Operator.CONTAINS); filter.setAttributeValue("key1=value1"); searchParameters.setEntityFilters(filter); AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertEquals(res.getEntities().size(), 1); }