Java Code Examples for org.apache.atlas.model.discovery.SearchParameters#setTypeName()
The following examples show how to use
org.apache.atlas.model.discovery.SearchParameters#setTypeName() .
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: 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 3
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 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(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 6
Source File: UserProfileServiceTest.java From atlas with Apache License 2.0 | 5 votes |
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 7
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void entityTypes() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE+","+HIVE_TABLE_TYPE); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 14); }
Example 8
Source File: FreeTextSearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@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 9
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@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 10
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 11
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void entityTypesAndTag() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE+","+HIVE_TABLE_TYPE); 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(), 3); }
Example 12
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@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 13
Source File: BasicSearchClassificationTest.java From atlas with Apache License 2.0 | 5 votes |
private int getEntityCount() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(ALL_ENTITY_TYPES); List<AtlasEntityHeader> entityHeaders = discoveryService.searchWithParameters(params).getEntities(); return entityHeaders.size(); }
Example 14
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@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 15
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 16
Source File: FreeTextSearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@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 17
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 18
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 19
Source File: TestEntitiesREST.java From atlas with Apache License 2.0 | 5 votes |
@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 20
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); }