Search in sources :

Example 11 with SearchFilter

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");
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) SearchFilter(org.apache.atlas.model.SearchFilter) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Example 12 with SearchFilter

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);
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) SearchFilter(org.apache.atlas.model.SearchFilter) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Example 13 with SearchFilter

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);
}
Also used : SearchFilter(org.apache.atlas.model.SearchFilter)

Example 14 with SearchFilter

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;
}
Also used : SearchFilter(org.apache.atlas.model.SearchFilter) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 15 with SearchFilter

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;
}
Also used : SearchFilter(org.apache.atlas.model.SearchFilter)

Aggregations

SearchFilter (org.apache.atlas.model.SearchFilter)20 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)14 Test (org.testng.annotations.Test)10 MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)7 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)6 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)4 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)2 BeforeTest (org.testng.annotations.BeforeTest)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 AtlasClientV2 (org.apache.atlas.AtlasClientV2)1 AtlasServiceException (org.apache.atlas.AtlasServiceException)1 AtlasSearchResult (org.apache.atlas.model.discovery.AtlasSearchResult)1 SearchParameters (org.apache.atlas.model.discovery.SearchParameters)1 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)1 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)1 AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)1