use of ai.grakn.engine.controller.response.ConceptBuilder in project grakn by graknlabs.
the class ConceptController method getConcept.
private String getConcept(Response response, Keyspace keyspace, Function<GraknTx, ai.grakn.concept.Concept> getter) throws JsonProcessingException {
response.type(APPLICATION_JSON);
try (GraknTx tx = factory.tx(keyspace, READ);
Timer.Context context = conceptIdGetTimer.time()) {
ai.grakn.concept.Concept concept = getter.apply(tx);
Optional<Concept> conceptWrapper = Optional.ofNullable(concept).map(ConceptBuilder::build);
if (conceptWrapper.isPresent()) {
response.status(SC_OK);
return objectMapper.writeValueAsString(conceptWrapper.get());
} else {
response.status(SC_NOT_FOUND);
return "";
}
}
}
Aggregations