use of ai.grakn.engine.controller.response.Things in project grakn by graknlabs.
the class ConceptController method getTypeInstances.
private String getTypeInstances(Request request, Response response) throws JsonProcessingException {
response.type(APPLICATION_JSON);
Keyspace keyspace = Keyspace.of(mandatoryPathParameter(request, KEYSPACE_PARAM));
Label label = Label.of(mandatoryPathParameter(request, LABEL_PARAMETER));
int offset = getOffset(request);
int limit = getLimit(request);
try (GraknTx tx = factory.tx(keyspace, READ);
Timer.Context context = instancesGetTimer.time()) {
Type type = tx.getType(label);
if (type == null) {
response.status(SC_NOT_FOUND);
return "";
}
// Get the wrapper
Things things = ConceptBuilder.buildThings(type, offset, limit);
response.status(SC_OK);
return objectMapper.writeValueAsString(things);
}
}