@Override
public ReadEntity getEntity(UUID id, Integer rev, Collection collection,
CustomEntityProperties customEntityProperties,
CustomRelationProperties customRelationProperties) throws NotFoundException {
GraphTraversal<Vertex, Vertex> fetchedEntity = entityFetcher.getEntity(
traversal,
id,
rev,
collection.getCollectionName()
);
if (!fetchedEntity.hasNext()) {
throw new NotFoundException();
}
Vertex entityVertex = entityFetcher.getEntity(traversal, id, rev, collection.getCollectionName()).next();
GraphTraversal<Vertex, Vertex> entityT = traversal.V(entityVertex.id());
if (!entityT.asAdmin().clone().hasNext()) {
throw new NotFoundException();
}
String entityTypesStr = getProp(entityT.asAdmin().clone().next(), "types", String.class).orElse("[]");
if (!entityTypesStr.contains("\"" + collection.getEntityTypeName() + "\"")) {
throw new NotFoundException();
}
return new TinkerPopToEntityMapper(collection, traversal, mappings, customEntityProperties,
customRelationProperties).mapEntity(entityT, true);
}