use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.
the class QueryFactoryTest method testCollectionQuery_PrefixQuery.
@Test
public void testCollectionQuery_PrefixQuery() throws Exception {
String queryString = "name:t*";
Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString);
QueryFactory factory = new QueryFactory();
AtlasTaxonomyQuery query = (AtlasTaxonomyQuery) factory.createTaxonomyQuery(request);
QueryExpression queryExpression = query.getQueryExpression();
assertEquals(queryExpression.getClass(), PrefixQueryExpression.class);
assertEquals(queryExpression.getField(), "name");
assertEquals(queryExpression.getExpectedValue(), "t");
assertEquals(query.getRequest(), request);
assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy");
}
use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.
the class EntityService method getEntityTags.
@GET
@Path("{entityId}/tags")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntityTags(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("entityId") String entityGuid) throws CatalogException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.getEntityTags(" + entityGuid + ")");
}
BaseRequest request = new CollectionRequest(Collections.<String, Object>singletonMap("id", entityGuid), decode(getQueryString(ui)));
Result result = getResources(entityTagResourceProvider, request);
return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.
the class EntityTagResourceDefinitionTest method testFilterProperties_Collection.
@Test
public void testFilterProperties_Collection() {
Map<String, Object> resourceProps = new HashMap<>();
resourceProps.put("id", "111-222-333");
resourceProps.put("name", "nameVal");
resourceProps.put("type", "someType");
resourceProps.put("foo", "fooVal");
resourceProps.put("bar", "barVal");
resourceProps.put("description", "desc");
resourceProps.put("creation_time", "2016:10:10");
resourceProps.put("acceptable_use", "something");
resourceProps.put("available_as_tag", true);
resourceProps.put("other", "otherVal");
Request request = new CollectionRequest(resourceProps, "someProperty:someValue");
request.addAdditionalSelectProperties(Collections.singleton("foo"));
ResourceDefinition entityTagDefinition = new EntityTagResourceDefinition();
Map<String, Object> filteredProps = entityTagDefinition.filterProperties(request, resourceProps);
assertEquals(filteredProps.size(), 3);
// registered collection props
assertTrue(filteredProps.containsKey("name"));
assertTrue(filteredProps.containsKey("description"));
// added prop
assertTrue(filteredProps.containsKey("foo"));
}
Aggregations