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; }
/** * 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; } }
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); final List<String> notNames = searchFilter.getParams(SearchFilter.PARAM_NOT_NAME);
/** * 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()); }
public SearchFilter(MultivaluedMap<String, String> params) { setParams(params); }
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); }
@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); } }
/** * 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()); }
@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); } }
public SearchFilter() { setParams(null); }
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 + "]"); } }
/** * 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()); }
public SearchFilter(MultivaluedMap<String, String> params) { setParams(params); }
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; }
public SearchFilter() { setParams(null); }
@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()); }
@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()); }
@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"); } }
@Test(dependsOnMethods = {"testGet"}, dataProvider = "validCreateDeptTypes") public void testCreateDept(AtlasTypesDef atlasTypesDef) { AtlasTypesDef existingTypesDef = null; try { existingTypesDef = typeDefStore.searchTypesDef(new SearchFilter()); } catch (AtlasBaseException e) { // ignore } assertNotEquals(atlasTypesDef, existingTypesDef, "Types to be created already exist in the system"); AtlasTypesDef createdTypesDef = null; try { createdTypesDef = typeDefStore.createTypesDef(atlasTypesDef); assertNotNull(createdTypesDef); assertTrue(createdTypesDef.getEnumDefs().containsAll(atlasTypesDef.getEnumDefs()), "EnumDefs create failed"); assertTrue(createdTypesDef.getClassificationDefs().containsAll(atlasTypesDef.getClassificationDefs()), "ClassificationDef create failed"); assertTrue(createdTypesDef.getStructDefs().containsAll(atlasTypesDef.getStructDefs()), "StructDef creation failed"); Assert.assertEquals(createdTypesDef.getEntityDefs(), atlasTypesDef.getEntityDefs()); } catch (AtlasBaseException e) { fail("Creation of Types should've been a success", e); } }