use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class EntityService method getEntity.
@GET
@Path("{entityId}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntity(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("entityId") String entityId) throws CatalogException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.getEntity(" + entityId + ")");
}
BaseRequest request = new InstanceRequest(Collections.<String, Object>singletonMap("id", entityId));
Result result = getResource(entityResourceProvider, request);
return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class EntityService method getEntityTag.
@GET
@Path("{entityId}/tags/{tag}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntityTag(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("entityId") String entityId, @PathParam("tag") String tagName) throws CatalogException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.getEntityTag(" + entityId + ", " + tagName + ")");
}
Map<String, Object> properties = new HashMap<>();
properties.put("id", entityId);
properties.put("name", tagName);
Result result = getResource(entityTagResourceProvider, new InstanceRequest(properties));
return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class EntityService method deleteEntityTag.
@DELETE
@Path("{entityId}/tags/{tag}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response deleteEntityTag(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("entityId") String entityId, @PathParam("tag") String tagName) throws CatalogException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.deleteEntityTag()");
}
Map<String, Object> properties = new HashMap<>();
properties.put("id", entityId);
properties.put("name", tagName);
deleteResource(entityTagResourceProvider, new InstanceRequest(properties));
return Response.status(Response.Status.OK).entity(new Results(ui.getRequestUri().toString(), 200)).build();
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class QueryFactoryTest method testCreateEntityTagQuery.
@Test
public void testCreateEntityTagQuery() throws Exception {
Map<String, Object> requestProps = new HashMap<>();
requestProps.put("id", "entity_id");
requestProps.put("name", "test_taxonomy.term1");
Request request = new InstanceRequest(requestProps);
QueryFactory factory = new QueryFactory();
AtlasEntityTagQuery query = (AtlasEntityTagQuery) factory.createEntityTagQuery(request);
QueryExpression queryExpression = query.getQueryExpression();
assertEquals(queryExpression.getClass(), TermQueryExpression.class);
assertEquals(queryExpression.getField(), "name");
assertEquals(queryExpression.getExpectedValue(), "test_taxonomy.term1");
assertEquals(query.getRequest(), request);
assertEquals(query.getResourceDefinition().getClass(), EntityTagResourceDefinition.class);
}
use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class TermResourceDefinitionTest method testValidate_nameOnly.
@Test
public void testValidate_nameOnly() throws Exception {
Map<String, Object> properties = new HashMap<>();
properties.put("name", "taxonomy1.termName");
Request request = new InstanceRequest(properties);
ResourceDefinition termDefinition = new TermResourceDefinition();
termDefinition.validateCreatePayload(request);
}
Aggregations