Search in sources :

Example 16 with SearchFilter

use of org.apache.atlas.model.SearchFilter in project atlas by apache.

the class AtlasTypeDefGraphStoreTest method testGet.

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

Example 17 with SearchFilter

use of org.apache.atlas.model.SearchFilter in project incubator-atlas by apache.

the class TypedefsJerseyResourceIT method testUpdate.

@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.");
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) 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 18 with SearchFilter

use of org.apache.atlas.model.SearchFilter in project incubator-atlas by apache.

the class QuickStartV2 method verifyTypesCreated.

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 + "]");
    }
}
Also used : MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) SearchFilter(org.apache.atlas.model.SearchFilter) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 19 with SearchFilter

use of org.apache.atlas.model.SearchFilter in project incubator-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)));
    }
    return ret;
}
Also used : SearchFilter(org.apache.atlas.model.SearchFilter)

Example 20 with SearchFilter

use of org.apache.atlas.model.SearchFilter in project incubator-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)

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