use of nl.knaw.huygens.timbuctoo.database.tinkerpop.Neo4jIndexHandler in project timbuctoo by HuygensING.
the class IndexAllEntityIds method execute.
@Override
public void execute(TinkerPopGraphManager graphManager) throws IOException {
Vres vres = getVres(graphManager);
Neo4jIndexHandler indexHandler = new Neo4jIndexHandler(graphManager);
ObjectMapper mapper = new ObjectMapper();
GraphTraversalSource traversalSource = graphManager.getGraph().traversal();
traversalSource.V().has(// only valid entities
"types").forEachRemaining(vertex -> {
try {
String[] types = mapper.readValue(vertex.<String>value("types"), String[].class);
for (String type : types) {
if (TYPES_TO_IGNORE.contains(type)) {
continue;
}
if (vres.getCollectionForType(type).isPresent()) {
VertexProperty<String> timIdProp = vertex.property("tim_id");
if (timIdProp.isPresent()) {
try {
UUID timId = UUID.fromString(timIdProp.value());
indexHandler.insertIntoIdIndex(timId, vertex);
} catch (IllegalArgumentException e) {
// This exception should not happen, but we do not want our migration to fail on it.
LOG.error("'{}' is not a valid id", timIdProp.value());
}
} else {
LOG.error("Vertex with id '{}' has no 'tim_id' property", vertex.id());
}
} else {
LOG.error("'{}' is not a known entity type.", type);
}
}
} catch (IOException e) {
LOG.error("And exception occurred while indexing vertex with vertex id '{}'.", vertex.id());
}
});
}
Aggregations