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");
}
}
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.");
}
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 + "]");
}
}
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;
}
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;
}
Aggregations