org.apache.atlas.model.SearchFilter Java Examples
The following examples show how to use
org.apache.atlas.model.SearchFilter.
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: TypesREST.java From atlas with Apache License 2.0 | 6 votes |
/** * Populate a SearchFilter on the basis of the Query Parameters * @return */ private SearchFilter getSearchFilter(HttpServletRequest httpServletRequest) { SearchFilter ret = new SearchFilter(); Set<String> keySet = httpServletRequest.getParameterMap().keySet(); for (String k : keySet) { String key = String.valueOf(k); String value = String.valueOf(httpServletRequest.getParameter(k)); if (key.equalsIgnoreCase("excludeInternalTypesAndReferences") && value.equalsIgnoreCase("true")) { FilterUtil.addParamsToHideInternalType(ret); } else { ret.setParam(key, value); } } return ret; }
Example #2
Source File: BulkFetchAndUpdate.java From atlas with Apache License 2.0 | 5 votes |
private List<AtlasClassificationDef> getAllClassificationsDefs() throws Exception { MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl(); searchParams.add(SearchFilter.PARAM_TYPE, "CLASSIFICATION"); SearchFilter searchFilter = new SearchFilter(searchParams); AtlasTypesDef typesDef = atlasClientV2.getAllTypeDefs(searchFilter); displayCrLf("Found classifications: " + typesDef.getClassificationDefs().size()); return typesDef.getClassificationDefs(); }
Example #3
Source File: NiFiAtlasClient.java From nifi with Apache License 2.0 | 5 votes |
private AtlasTypesDef getTypeDefs(String ... typeNames) throws AtlasServiceException { final AtlasTypesDef typeDefs = new AtlasTypesDef(); for (int i = 0; i < typeNames.length; i++) { final MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl(); searchParams.add(SearchFilter.PARAM_NAME, typeNames[i]); final AtlasTypesDef typeDef = atlasClient.getAllTypeDefs(new SearchFilter(searchParams)); typeDefs.getEntityDefs().addAll(typeDef.getEntityDefs()); } logger.debug("typeDefs={}", typeDefs); return typeDefs; }
Example #4
Source File: AtlasTypeDefGraphStoreTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Test(dependsOnMethods = "testGet") public void testSearchFunctionality() { SearchFilter searchFilter = new SearchFilter(); searchFilter.setParam(SearchFilter.PARAM_SUPERTYPE, "Person"); try { AtlasTypesDef typesDef = typeDefStore.searchTypesDef(searchFilter); assertNotNull(typesDef); assertNotNull(typesDef.getEntityDefs()); assertEquals(typesDef.getEntityDefs().size(), 3); } catch (AtlasBaseException e) { fail("Search should've succeeded", e); } }
Example #5
Source File: AtlasTypeDefGraphStoreTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Test(priority = 1) public void testGet() { try { AtlasTypesDef typesDef = typeDefStore.searchTypesDef(new SearchFilter()); assertNotNull(typesDef.getEnumDefs()); assertEquals(typesDef.getStructDefs().size(), 0); assertNotNull(typesDef.getStructDefs()); assertEquals(typesDef.getClassificationDefs().size(), 0); assertNotNull(typesDef.getClassificationDefs()); assertEquals(typesDef.getEntityDefs().size(), 0); assertNotNull(typesDef.getEntityDefs()); } catch (AtlasBaseException e) { fail("Search of types shouldn't have failed"); } }
Example #6
Source File: AtlasTypeDefGraphStore.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException { final AtlasTypesDef typesDef = new AtlasTypesDef(); Predicate searchPredicates = FilterUtil.getPredicateFromSearchFilter(searchFilter); for(AtlasEnumType enumType : typeRegistry.getAllEnumTypes()) { if (searchPredicates.evaluate(enumType)) { typesDef.getEnumDefs().add(enumType.getEnumDef()); } } for(AtlasStructType structType : typeRegistry.getAllStructTypes()) { if (searchPredicates.evaluate(structType)) { typesDef.getStructDefs().add(structType.getStructDef()); } } for(AtlasClassificationType classificationType : typeRegistry.getAllClassificationTypes()) { if (searchPredicates.evaluate(classificationType)) { typesDef.getClassificationDefs().add(classificationType.getClassificationDef()); } } for(AtlasEntityType entityType : typeRegistry.getAllEntityTypes()) { if (searchPredicates.evaluate(entityType)) { typesDef.getEntityDefs().add(entityType.getEntityDef()); } } for(AtlasRelationshipType relationshipType : typeRegistry.getAllRelationshipTypes()) { if (searchPredicates.evaluate(relationshipType)) { typesDef.getRelationshipDefs().add(relationshipType.getRelationshipDef()); } } return typesDef; }
Example #7
Source File: FilterUtil.java From incubator-atlas with Apache License 2.0 | 5 votes |
public static Predicate getPredicateFromSearchFilter(SearchFilter searchFilter) { List<Predicate> predicates = new ArrayList<>(); final String type = searchFilter.getParam(SearchFilter.PARAM_TYPE); final String name = searchFilter.getParam(SearchFilter.PARAM_NAME); final String supertype = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE); final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE); // Add filter for the type/category if (StringUtils.isNotBlank(type)) { predicates.add(getTypePredicate(type)); } // Add filter for the name if (StringUtils.isNotBlank(name)) { predicates.add(getNamePredicate(name)); } // Add filter for the supertype if (StringUtils.isNotBlank(supertype)) { predicates.add(getSuperTypePredicate(supertype)); } // Add filter for the supertype negation if (StringUtils.isNotBlank(notSupertype)) { predicates.add(new NotPredicate(getSuperTypePredicate(notSupertype))); } return PredicateUtils.allPredicate(predicates); }
Example #8
Source File: QuickStartV2.java From incubator-atlas with Apache License 2.0 | 5 votes |
private void verifyTypesCreated() throws Exception { MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl(); for (String typeName : TYPES) { searchParams.clear(); searchParams.add(SearchFilter.PARAM_NAME, typeName); SearchFilter searchFilter = new SearchFilter(searchParams); AtlasTypesDef searchDefs = atlasClientV2.getAllTypeDefs(searchFilter); assert (!searchDefs.isEmpty()); System.out.println("Created type [" + typeName + "]"); } }
Example #9
Source File: TypesREST.java From incubator-atlas with Apache License 2.0 | 5 votes |
/** * Populate a SearchFilter on the basis of the Query Parameters * @return */ private SearchFilter getSearchFilter(HttpServletRequest httpServletRequest) { SearchFilter ret = new SearchFilter(); Set<String> keySet = httpServletRequest.getParameterMap().keySet(); for (String key : keySet) { ret.setParam(String.valueOf(key), String.valueOf(httpServletRequest.getParameter(key))); } return ret; }
Example #10
Source File: TypesREST.java From incubator-atlas with Apache License 2.0 | 5 votes |
/** * Bulk retrieval API for retrieving all type definitions in Atlas * @return A composite wrapper object with lists of all type definitions * @throws Exception * @HTTP 200 {@link AtlasTypesDef} with type definitions matching the search criteria or else returns empty list of type definitions */ @GET @Path("/typedefs") @Produces(Servlets.JSON_MEDIA_TYPE) public AtlasTypesDef getAllTypeDefs(@Context HttpServletRequest httpServletRequest) throws AtlasBaseException { SearchFilter searchFilter = getSearchFilter(httpServletRequest); AtlasTypesDef typesDef = typeDefStore.searchTypesDef(searchFilter); return typesDef; }
Example #11
Source File: TypesREST.java From incubator-atlas with Apache License 2.0 | 5 votes |
/** * Bulk retrieval API for all type definitions returned as a list of minimal information header * @return List of AtlasTypeDefHeader {@link AtlasTypeDefHeader} * @throws AtlasBaseException * @HTTP 200 Returns a list of {@link AtlasTypeDefHeader} matching the search criteria * or an empty list if no match. */ @GET @Path("/typedefs/headers") @Produces(Servlets.JSON_MEDIA_TYPE) public List<AtlasTypeDefHeader> getTypeDefHeaders(@Context HttpServletRequest httpServletRequest) throws AtlasBaseException { SearchFilter searchFilter = getSearchFilter(httpServletRequest); AtlasTypesDef searchTypesDef = typeDefStore.searchTypesDef(searchFilter); return AtlasTypeUtil.toTypeDefHeader(searchTypesDef); }
Example #12
Source File: TypesREST.java From atlas with Apache License 2.0 | 5 votes |
/** * Bulk retrieval API for all type definitions returned as a list of minimal information header * @return List of AtlasTypeDefHeader {@link AtlasTypeDefHeader} * @throws AtlasBaseException * @HTTP 200 Returns a list of {@link AtlasTypeDefHeader} matching the search criteria * or an empty list if no match. */ @GET @Path("/typedefs/headers") public List<AtlasTypeDefHeader> getTypeDefHeaders(@Context HttpServletRequest httpServletRequest) throws AtlasBaseException { SearchFilter searchFilter = getSearchFilter(httpServletRequest); AtlasTypesDef searchTypesDef = typeDefStore.searchTypesDef(searchFilter); return AtlasTypeUtil.toTypeDefHeader(searchTypesDef); }
Example #13
Source File: AtlasTypeDefGraphStoreTest.java From atlas with Apache License 2.0 | 5 votes |
@Test(dependsOnMethods = "testGet") public void testSearchFunctionality() { SearchFilter searchFilter = new SearchFilter(); searchFilter.setParam(SearchFilter.PARAM_SUPERTYPE, "Person"); try { AtlasTypesDef typesDef = typeDefStore.searchTypesDef(searchFilter); assertNotNull(typesDef); assertNotNull(typesDef.getEntityDefs()); assertEquals(typesDef.getEntityDefs().size(), 3); } catch (AtlasBaseException e) { fail("Search should've succeeded", e); } }
Example #14
Source File: AtlasTypeDefGraphStoreTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void testGet() { try { AtlasTypesDef typesDef = typeDefStore.searchTypesDef(new SearchFilter()); assertNotNull(typesDef.getEnumDefs()); assertEquals(typesDef.getStructDefs().size(), 0); assertNotNull(typesDef.getStructDefs()); assertEquals(typesDef.getClassificationDefs().size(), 0); assertNotNull(typesDef.getClassificationDefs()); assertEquals(typesDef.getEntityDefs().size(), 0); assertNotNull(typesDef.getEntityDefs()); } catch (AtlasBaseException e) { fail("Search of types shouldn't have failed"); } }
Example #15
Source File: QuickStartV2.java From atlas with Apache License 2.0 | 5 votes |
private void verifyTypesCreated() throws Exception { MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl(); for (String typeName : TYPES) { searchParams.clear(); searchParams.add(SearchFilter.PARAM_NAME, typeName); SearchFilter searchFilter = new SearchFilter(searchParams); AtlasTypesDef searchDefs = atlasClientV2.getAllTypeDefs(searchFilter); assert (!searchDefs.isEmpty()); System.out.println("Created type [" + typeName + "]"); } }
Example #16
Source File: TypesREST.java From atlas with Apache License 2.0 | 5 votes |
/** * Bulk retrieval API for retrieving all type definitions in Atlas * @return A composite wrapper object with lists of all type definitions * @throws Exception * @HTTP 200 {@link AtlasTypesDef} with type definitions matching the search criteria or else returns empty list of type definitions */ @GET @Path("/typedefs") public AtlasTypesDef getAllTypeDefs(@Context HttpServletRequest httpServletRequest) throws AtlasBaseException { SearchFilter searchFilter = getSearchFilter(httpServletRequest); AtlasTypesDef typesDef = typeDefStore.searchTypesDef(searchFilter); return typesDef; }
Example #17
Source File: AtlasTypeDefGraphStore.java From atlas with Apache License 2.0 | 4 votes |
@Override public AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException { final AtlasTypesDef typesDef = new AtlasTypesDef(); Predicate searchPredicates = FilterUtil.getPredicateFromSearchFilter(searchFilter); for(AtlasEnumType enumType : typeRegistry.getAllEnumTypes()) { if (searchPredicates.evaluate(enumType)) { typesDef.getEnumDefs().add(enumType.getEnumDef()); } } for(AtlasStructType structType : typeRegistry.getAllStructTypes()) { if (searchPredicates.evaluate(structType)) { typesDef.getStructDefs().add(structType.getStructDef()); } } for(AtlasClassificationType classificationType : typeRegistry.getAllClassificationTypes()) { if (searchPredicates.evaluate(classificationType)) { typesDef.getClassificationDefs().add(classificationType.getClassificationDef()); } } for(AtlasEntityType entityType : typeRegistry.getAllEntityTypes()) { if (searchPredicates.evaluate(entityType)) { typesDef.getEntityDefs().add(entityType.getEntityDef()); } } for(AtlasRelationshipType relationshipType : typeRegistry.getAllRelationshipTypes()) { if (searchPredicates.evaluate(relationshipType)) { typesDef.getRelationshipDefs().add(relationshipType.getRelationshipDef()); } } for(AtlasBusinessMetadataType businessMetadataType : typeRegistry.getAllBusinessMetadataTypes()) { if (searchPredicates.evaluate(businessMetadataType)) { typesDef.getBusinessMetadataDefs().add(businessMetadataType.getBusinessMetadataDef()); } } return typesDef; }
Example #18
Source File: TypedefsJerseyResourceIT.java From incubator-atlas with Apache License 2.0 | 4 votes |
@Test public void testUpdate() throws Exception { String entityType = randomString(); AtlasEntityDef typeDefinition = createClassTypeDef(entityType, ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string")); AtlasTypesDef atlasTypesDef = new AtlasTypesDef(); atlasTypesDef.getEntityDefs().add(typeDefinition); AtlasTypesDef createdTypeDefs = clientV2.createAtlasTypeDefs(atlasTypesDef); assertNotNull(createdTypeDefs); assertEquals(createdTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size()); //Add attribute description typeDefinition = createClassTypeDef(typeDefinition.getName(), ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createOptionalAttrDef("description", "string")); emptyTypeDefs(atlasTypesDef); atlasTypesDef.getEntityDefs().add(typeDefinition); AtlasTypesDef updatedTypeDefs = clientV2.updateAtlasTypeDefs(atlasTypesDef); assertNotNull(updatedTypeDefs); assertEquals(updatedTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size()); assertEquals(updatedTypeDefs.getEntityDefs().get(0).getName(), atlasTypesDef.getEntityDefs().get(0).getName()); MultivaluedMap<String, String> filterParams = new MultivaluedMapImpl(); filterParams.add(SearchFilter.PARAM_TYPE, "ENTITY"); AtlasTypesDef allTypeDefs = clientV2.getAllTypeDefs(new SearchFilter(filterParams)); assertNotNull(allTypeDefs); Boolean entityDefFound = false; for (AtlasEntityDef atlasEntityDef : allTypeDefs.getEntityDefs()){ if (atlasEntityDef.getName().equals(typeDefinition.getName())) { assertEquals(atlasEntityDef.getAttributeDefs().size(), 2); entityDefFound = true; break; } } assertTrue(entityDefFound, "Required entityDef not found."); }
Example #19
Source File: FilterUtil.java From atlas with Apache License 2.0 | 4 votes |
public static void addParamsToHideInternalType(SearchFilter searchFilter) { searchFilter.setParam(SearchFilter.PARAM_NOT_NAME, Constants.TYPE_NAME_INTERNAL); searchFilter.setParam(SearchFilter.PARAM_NOT_SUPERTYPE, Constants.TYPE_NAME_INTERNAL); }
Example #20
Source File: FilterUtil.java From atlas with Apache License 2.0 | 4 votes |
public static Predicate getPredicateFromSearchFilter(SearchFilter searchFilter) { List<Predicate> predicates = new ArrayList<>(); final String type = searchFilter.getParam(SearchFilter.PARAM_TYPE); final String name = searchFilter.getParam(SearchFilter.PARAM_NAME); final String supertype = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE); final String serviceType = searchFilter.getParam(SearchFilter.PARAM_SERVICETYPE); final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE); final String notServiceType = searchFilter.getParam(SearchFilter.PARAM_NOT_SERVICETYPE); final List<String> notNames = searchFilter.getParams(SearchFilter.PARAM_NOT_NAME); // Add filter for the type/category if (StringUtils.isNotBlank(type)) { predicates.add(getTypePredicate(type)); } // Add filter for the name if (StringUtils.isNotBlank(name)) { predicates.add(getNamePredicate(name)); } // Add filter for the serviceType if(StringUtils.isNotBlank(serviceType)) { predicates.add(getServiceTypePredicate(serviceType)); } // Add filter for the supertype if (StringUtils.isNotBlank(supertype)) { predicates.add(getSuperTypePredicate(supertype)); } // Add filter for the supertype negation if (StringUtils.isNotBlank(notSupertype)) { predicates.add(new NotPredicate(getSuperTypePredicate(notSupertype))); } // Add filter for the serviceType negation // NOTE: Creating code for the exclusion of multiple service types is currently useless. // In fact the getSearchFilter in TypeREST.java uses the HttpServletRequest.getParameter(key) // that if the key takes more values it takes only the first the value. Could be useful // to change the getSearchFilter to use getParameterValues instead of getParameter. if (StringUtils.isNotBlank(notServiceType)) { predicates.add(new NotPredicate(getServiceTypePredicate(notServiceType))); } // Add filter for the type negation if (CollectionUtils.isNotEmpty(notNames)) { for (String notName : notNames) { predicates.add(new NotPredicate(getNamePredicate(notName))); } } return PredicateUtils.allPredicate(predicates); }
Example #21
Source File: TypedefsJerseyResourceIT.java From atlas with Apache License 2.0 | 4 votes |
@Test public void testUpdate() throws Exception { String entityType = randomString(); AtlasEntityDef typeDefinition = createClassTypeDef(entityType, Collections.<String>emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string")); AtlasTypesDef atlasTypesDef = new AtlasTypesDef(); atlasTypesDef.getEntityDefs().add(typeDefinition); AtlasTypesDef createdTypeDefs = clientV2.createAtlasTypeDefs(atlasTypesDef); assertNotNull(createdTypeDefs); assertEquals(createdTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size()); //Add attribute description typeDefinition = createClassTypeDef(typeDefinition.getName(), Collections.<String>emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createOptionalAttrDef("description", "string")); emptyTypeDefs(atlasTypesDef); atlasTypesDef.getEntityDefs().add(typeDefinition); AtlasTypesDef updatedTypeDefs = clientV2.updateAtlasTypeDefs(atlasTypesDef); assertNotNull(updatedTypeDefs); assertEquals(updatedTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size()); assertEquals(updatedTypeDefs.getEntityDefs().get(0).getName(), atlasTypesDef.getEntityDefs().get(0).getName()); MultivaluedMap<String, String> filterParams = new MultivaluedMapImpl(); filterParams.add(SearchFilter.PARAM_TYPE, "ENTITY"); AtlasTypesDef allTypeDefs = clientV2.getAllTypeDefs(new SearchFilter(filterParams)); assertNotNull(allTypeDefs); Boolean entityDefFound = false; for (AtlasEntityDef atlasEntityDef : allTypeDefs.getEntityDefs()){ if (atlasEntityDef.getName().equals(typeDefinition.getName())) { assertEquals(atlasEntityDef.getAttributeDefs().size(), 2); entityDefFound = true; break; } } assertTrue(entityDefFound, "Required entityDef not found."); }
Example #22
Source File: UserProfileServiceTest.java From atlas with Apache License 2.0 | 3 votes |
@Test public void filterInternalType() throws AtlasBaseException { SearchFilter searchFilter = new SearchFilter(); FilterUtil.addParamsToHideInternalType(searchFilter); AtlasTypesDef filteredTypeDefs = typeDefStore.searchTypesDef(searchFilter); assertNotNull(filteredTypeDefs); Optional<AtlasEntityDef> anyInternal = filteredTypeDefs.getEntityDefs().stream().filter(e -> e.getSuperTypes().contains("__internal")).findAny(); assertFalse(anyInternal.isPresent()); }
Example #23
Source File: AtlasClientV2.java From atlas with Apache License 2.0 | 2 votes |
/** * Bulk retrieval API for retrieving all type definitions in Atlas * * @return A composite wrapper object with lists of all type definitions */ public AtlasTypesDef getAllTypeDefs(SearchFilter searchFilter) throws AtlasServiceException { return callAPI(API_V2.GET_ALL_TYPE_DEFS, AtlasTypesDef.class, searchFilter.getParams()); }
Example #24
Source File: AtlasClientV2.java From incubator-atlas with Apache License 2.0 | 2 votes |
/** * Bulk retrieval API for retrieving all type definitions in Atlas * * @return A composite wrapper object with lists of all type definitions */ public AtlasTypesDef getAllTypeDefs(SearchFilter searchFilter) throws AtlasServiceException { return callAPI(GET_ALL_TYPE_DEFS, AtlasTypesDef.class, searchFilter.getParams()); }
Example #25
Source File: AtlasTypeDefStore.java From atlas with Apache License 2.0 | votes |
AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException;
Example #26
Source File: AtlasTypeDefStore.java From incubator-atlas with Apache License 2.0 | votes |
AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException;