use of org.apache.atlas.model.SearchFilter in project incubator-atlas by apache.
the class AtlasTypeDefGraphStoreTest method testGet.
@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");
}
}
use of org.apache.atlas.model.SearchFilter in project incubator-atlas by apache.
the class TypedefsJerseyResourceIT method testListTypesByFilter.
@Test
public void testListTypesByFilter() throws Exception {
AtlasAttributeDef attr = AtlasTypeUtil.createOptionalAttrDef("attr", "string");
AtlasEntityDef classDefA = AtlasTypeUtil.createClassTypeDef("A" + randomString(), ImmutableSet.<String>of(), attr);
AtlasEntityDef classDefA1 = AtlasTypeUtil.createClassTypeDef("A1" + randomString(), ImmutableSet.of(classDefA.getName()), attr);
AtlasEntityDef classDefB = AtlasTypeUtil.createClassTypeDef("B" + randomString(), ImmutableSet.<String>of(), attr);
AtlasEntityDef classDefC = AtlasTypeUtil.createClassTypeDef("C" + randomString(), ImmutableSet.of(classDefB.getName(), classDefA.getName()), attr);
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEntityDefs().add(classDefA);
atlasTypesDef.getEntityDefs().add(classDefA1);
atlasTypesDef.getEntityDefs().add(classDefB);
atlasTypesDef.getEntityDefs().add(classDefC);
AtlasTypesDef created = clientV2.createAtlasTypeDefs(atlasTypesDef);
assertNotNull(created);
assertEquals(created.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size());
MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl();
searchParams.add(SearchFilter.PARAM_TYPE, "CLASS");
searchParams.add(SearchFilter.PARAM_SUPERTYPE, classDefA.getName());
SearchFilter searchFilter = new SearchFilter(searchParams);
AtlasTypesDef searchDefs = clientV2.getAllTypeDefs(searchFilter);
assertNotNull(searchDefs);
assertEquals(searchDefs.getEntityDefs().size(), 2);
searchParams.add(SearchFilter.PARAM_NOT_SUPERTYPE, classDefB.getName());
searchFilter = new SearchFilter(searchParams);
searchDefs = clientV2.getAllTypeDefs(searchFilter);
assertNotNull(searchDefs);
assertEquals(searchDefs.getEntityDefs().size(), 1);
}
use of org.apache.atlas.model.SearchFilter in project incubator-atlas by apache.
the class TypesREST method getTypeDefHeaders.
/**
* 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);
}
use of org.apache.atlas.model.SearchFilter in project atlas by apache.
the class TypesREST method getAllTypeDefs.
/**
* 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;
}
use of org.apache.atlas.model.SearchFilter in project atlas by apache.
the class TypesREST method getSearchFilter.
/**
* 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)));
}
FilterUtil.addParamsToHideInternalType(ret);
return ret;
}
Aggregations