Search in sources :

Example 6 with RdfProperty

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

the class TinkerPopOperationsTest method assertPropertyWillKeepTrackOfThePredicate.

@Test
public void assertPropertyWillKeepTrackOfThePredicate() {
    TinkerPopOperations instance = TinkerPopOperationsStubs.newInstance();
    Vre vre = instance.ensureVreExists("vre");
    instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
    instance.addPredicateValueTypeVertexToVre(vre);
    vre = instance.loadVres().getVre("vre");
    Collection defaultCollection = vre.getCollectionForTypeName(defaultEntityTypeName(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"));
    instance.assertProperty(vre, "http://example.org/2", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/2001/XMLSchema#float"));
    List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
    assertThat(predicates, contains(hasProperty("predicateUri", equalTo("http://example.org/propName"))));
    List<ValueTypeInUse> valueTypes = predicates.get(0).getValueTypes();
    assertThat(valueTypes, containsInAnyOrder(allOf(hasProperty("typeUri", equalTo("http://www.w3.org/2001/XMLSchema#float")), hasProperty("entitiesConnected", contains("http://example.org/2"))), allOf(hasProperty("typeUri", equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")), hasProperty("entitiesConnected", contains("http://example.org/1")))));
}
Also used : ValueTypeInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse) 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 7 with RdfProperty

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

the class TinkerPopOperationsTest method retractPropertyRemovesTheProperty.

@Test
public void retractPropertyRemovesTheProperty() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    Vre vre = minimalCorrectVre(instance, "vre");
    instance.assertEntity(vre, "http://example.org/1");
    long minimalPropertyCount = graphManager.getGraph().traversal().V().has(RDF_URI_PROP, "http://example.org/1").properties().count().next();
    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"));
    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").properties().count().next() - minimalPropertyCount;
    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)

Example 8 with RdfProperty

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

the class TinkerPopOperationsTest method assertPropertyAddsThePropertyOnTheEntity.

@Test
public void assertPropertyAddsThePropertyOnTheEntity() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    String vreName = "vre";
    Vre vre = minimalCorrectVre(instance, vreName);
    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) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with RdfProperty

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

the class TinkerPopOperationsTest method retractPropertyRemovesTheValueTypeFromThePredicateIfItDoesNotApplyToAnyEntity.

@Test
public void retractPropertyRemovesTheValueTypeFromThePredicateIfItDoesNotApplyToAnyEntity() {
    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");
    RdfProperty floatProperty = new RdfProperty("http://example.org/propName", "1.5", "http://www.w3.org/2001/XMLSchema#float");
    instance.assertProperty(vre, "http://example.org/1", stringProperty);
    instance.assertProperty(vre, "http://example.org/2", floatProperty);
    instance.assertProperty(vre, "http://example.org/3", floatProperty);
    instance.retractProperty(vre, "http://example.org/1", stringProperty);
    instance.retractProperty(vre, "http://example.org/2", floatProperty);
    List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
    assertThat(predicates, hasSize(1));
    assertThat(predicates.get(0).getValueTypes(), contains(hasProperty("typeUri", equalTo("http://www.w3.org/2001/XMLSchema#float"))));
}
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 10 with RdfProperty

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

the class TinkerPopOperationsTest method assertPropertyOverwritesThePropertyOnTheEntity.

@Test
public void assertPropertyOverwritesThePropertyOnTheEntity() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    String vreName = "vre";
    Vre vre = minimalCorrectVre(instance, vreName);
    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"));
    instance.assertProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "somethingCompletelyDifferent", "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("somethingCompletelyDifferent"));
}
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) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) 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