use of nl.knaw.huygens.timbuctoo.database.tinkerpop.conversion.TinkerPopPropertyConverter in project timbuctoo by HuygensING.
the class TinkerPopOperations method assertProperty.
@Override
public void assertProperty(Vre vre, String entityRdfUri, RdfProperty property) {
Vertex vertex = assertEntity(vre, entityRdfUri);
Object value;
try {
// The TinkerPopConverter does not need a collection for the external -> db case.
// It does need one for the db -> external case (but we're not using that one here)
TinkerPopPropertyConverter propertyConverter = new TinkerPopPropertyConverter(null);
Tuple<String, Object> convert = property.getTimProperty().convert(propertyConverter);
value = convert.getRight();
} catch (IOException e) {
LOG.error("Could not parse timproperty of '{}' with value '{}' for entity '{}'", property.getPredicateUri(), property.getValue(), entityRdfUri);
value = property.getValue();
}
// to be able to use the value in a lambda
final Object val = value;
collectionsFor(vertex).forEachRemaining(collection -> {
getProp(collection, ENTITY_TYPE_NAME_PROPERTY_NAME, String.class).ifPresent(entityTypeName -> {
vertex.property(createPropName(entityTypeName, property.getPredicateUri()), val);
});
});
assertPredicateAndValueType(vertex, getPredicateValueTypeVertexFor(vre), property);
committer.tick();
}
Aggregations