Search in sources :

Example 1 with RdfProperty

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty in project timbuctoo by HuygensING.

the class PropertyTripleProcessor method processAssertion.

@Override
protected void processAssertion(String vreName, String subject, String predicate, String lexicalValue, String typeUri) {
    RdfProperty property = new RdfProperty(predicate, lexicalValue, typeUri);
    // FIXME Add support for multiple value types
    rdfImportSession.assertProperty(subject, property);
}
Also used : RdfProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty)

Example 2 with RdfProperty

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty in project timbuctoo by HuygensING.

the class TinkerPopOperationsTest method assertPropertyAlsoAddsAnAdminVersionOfTheProperty.

@Test
public void assertPropertyAlsoAddsAnAdminVersionOfTheProperty() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    Vre vre = minimalCorrectVre(instance, "vre");
    instance.assertProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
    List<Object> values = graphManager.getGraph().traversal().V().values(defaultEntityTypeName("vre") + "_" + "http://example.org/propName").toList();
    assertThat(values, contains("value"));
}
Also used : TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) RdfProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) Test(org.junit.Test)

Example 3 with RdfProperty

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty in project timbuctoo by HuygensING.

the class TinkerPopOperationsTest method retractRemovesThePredicateWhenNoValueTypesAreConnected.

@Test
public void retractRemovesThePredicateWhenNoValueTypesAreConnected() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    Vre vre = minimalCorrectVre(instance, "vre");
    Collection defaultCollection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
    RdfProperty stringProperty = new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
    instance.assertProperty(vre, "http://example.org/1", stringProperty);
    instance.retractProperty(vre, "http://example.org/1", stringProperty);
    List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
    assertThat(predicates, is(empty()));
}
Also used : TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) RdfProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) CreateCollection(nl.knaw.huygens.timbuctoo.core.dto.CreateCollection) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) PredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse) Test(org.junit.Test)

Example 4 with RdfProperty

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty 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));
}
Also used : TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) RdfProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty) RdfReadProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 5 with RdfProperty

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty in project timbuctoo by HuygensING.

the class TinkerPopOperationsTest method retractPropertyWillBeANoopIfTheEntityDoesNotYetExist.

@Test
public void retractPropertyWillBeANoopIfTheEntityDoesNotYetExist() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    Vre vre = instance.ensureVreExists("vre");
    instance.retractProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "somethingCompletelyDifferent", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
    Long entitiesWithPropName = graphManager.getGraph().traversal().V().has(RDF_URI_PROP, "http://example.org/1").count().next();
    assertThat(entitiesWithPropName, is(0L));
}
Also used : TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) RdfProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) Test(org.junit.Test)

Aggregations

RdfProperty (nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty)11 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)9 VreStubs.minimalCorrectVre (nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre)9 Test (org.junit.Test)9 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)8 CreateCollection (nl.knaw.huygens.timbuctoo.core.dto.CreateCollection)3 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)3 PredicateInUse (nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Matchers.anyString (org.mockito.Matchers.anyString)3 RdfReadProperty (nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty)1 ValueTypeInUse (nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse)1