use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retrievePropertyReturnsThePropertyOfTheEntity.
@Test
public void retrievePropertyReturnsThePropertyOfTheEntity() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
String vreName = "vre";
Vre vre = minimalCorrectVre(instance, vreName);
String entityRdfUri = "http://example.org/1";
String predicateUri = "http://example.org/propName";
String value = "value";
instance.assertProperty(vre, entityRdfUri, new RdfProperty(predicateUri, value, "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
Optional<RdfReadProperty> rdfProperty = instance.retrieveProperty(vre, entityRdfUri, predicateUri);
assertThat(rdfProperty, is(present()));
assertThat(rdfProperty.get().getValue(), is(value));
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retrievePropertyReturnsAnEmtptyOptionWhenTheVertexDoesNotContainTheProperty.
@Test
public void retrievePropertyReturnsAnEmtptyOptionWhenTheVertexDoesNotContainTheProperty() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
String vreName = "vre";
Vre vre = minimalCorrectVre(instance, vreName);
String entityRdfUri = "http://example.org/1";
String predicateUri = "http://example.org/propName";
// make sure the vertex exist
instance.assertEntity(vre, entityRdfUri);
Optional<RdfReadProperty> rdfProperty = instance.retrieveProperty(vre, entityRdfUri, predicateUri);
assertThat(rdfProperty, is(not(present())));
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty in project timbuctoo by HuygensING.
the class TinkerPopOperations method retrieveProperty.
@Override
public Optional<RdfReadProperty> retrieveProperty(Vre vre, String entityRdfUri, String propertyUri) {
Optional<Vertex> entityOpt = indexHandler.findVertexInRdfIndex(vre, entityRdfUri);
if (entityOpt.isPresent()) {
Vertex entity = entityOpt.get();
Iterable<Vertex> collectionOfEntity = () -> collectionsFor(entity);
Optional<Collection> colOpt = StreamSupport.stream(collectionOfEntity.spliterator(), false).map(col -> getProp(col, COLLECTION_NAME_PROPERTY_NAME, String.class)).filter(colNameProp -> colNameProp.isPresent()).map(colNameProp -> colNameProp.get()).map(vre::getCollectionForCollectionName).filter(Optional::isPresent).map(Optional::get).findFirst();
if (colOpt.isPresent()) {
Collection collection = colOpt.get();
VertexProperty<String> property = entity.property(createPropName(collection.getEntityTypeName(), propertyUri));
if (property.isPresent()) {
return Optional.of(new RdfReadProperty(propertyUri, property.value()));
}
}
}
return Optional.empty();
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retrievePropertyReturnsAnEmptyOptionalWhenTheEntityDoesNotExist.
@Test
public void retrievePropertyReturnsAnEmptyOptionalWhenTheEntityDoesNotExist() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
String vreName = "vre";
Vre vre = minimalCorrectVre(instance, vreName);
String entityRdfUri = "http://example.org/1";
String predicateUri = "http://example.org/propName";
Optional<RdfReadProperty> rdfProperty = instance.retrieveProperty(vre, entityRdfUri, predicateUri);
assertThat(rdfProperty, is(not(present())));
}
Aggregations