Search in sources :

Example 1 with PredicateInUse

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse 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 2 with PredicateInUse

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse 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 3 with PredicateInUse

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

the class PropertyFactoryTest method fromRdfPredicateWillNotCreateTheSameClientNameTwice.

@Test
public void fromRdfPredicateWillNotCreateTheSameClientNameTwice() {
    ValueTypeInUse valueType1 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type1").addEntitiesConnected("entity1", "entity2").build();
    List<PredicateInUse> predicates = Lists.newArrayList(ImmutablePredicateInUse.builder().predicateUri("http://example.org/localName").addValueTypes(valueType1).build(), ImmutablePredicateInUse.builder().predicateUri("http://example.com/localName").addValueTypes(valueType1).build());
    List<CreateProperty> properties = instance.fromPredicates(predicates);
    assertThat(properties, containsInAnyOrder(allOf(hasProperty("clientName", equalTo("localName")), hasProperty("rdfUri", equalTo("http://example.org/localName"))), allOf(hasProperty("clientName", equalTo("http://example.com/localName")), hasProperty("rdfUri", equalTo("http://example.com/localName")))));
}
Also used : CreateProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.CreateProperty) ValueTypeInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse) ImmutableValueTypeInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableValueTypeInUse) PredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse) ImmutablePredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutablePredicateInUse) Test(org.junit.Test)

Example 4 with PredicateInUse

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

the class PropertyFactoryTest method createPredicates.

private List<PredicateInUse> createPredicates() {
    ValueTypeInUse valueType1 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type1").addEntitiesConnected("entity1", "entity2").build();
    ValueTypeInUse valueType2 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type2").addEntitiesConnected("entity3").build();
    PredicateInUse pred1 = ImmutablePredicateInUse.builder().predicateUri("http://example.org/test#pred1").addValueTypes(valueType1, valueType2).build();
    ValueTypeInUse valueType3 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type3").addEntitiesConnected("entity1").build();
    ValueTypeInUse valueType4 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type4").addEntitiesConnected("entity3", "entity2").build();
    PredicateInUse pred2 = ImmutablePredicateInUse.builder().predicateUri("http://example.org/pred2").addValueTypes(valueType3, valueType4).build();
    return Lists.newArrayList(pred1, pred2);
}
Also used : ValueTypeInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse) ImmutableValueTypeInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableValueTypeInUse) PredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse) ImmutablePredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutablePredicateInUse)

Example 5 with PredicateInUse

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

the class RdfImportSession method close.

public void close() {
    Vre reloadedVre = dataStoreOperations.loadVres().getVre(this.vre.getVreName());
    if (sessionState == SessionState.SUCCESS) {
        dataStoreOperations.getEntitiesWithUnknownType(reloadedVre).forEach(entityUri -> errorReporter.entityTypeUnknown(entityUri));
        dataStoreOperations.finishEntities(reloadedVre, entityFinisherHelper);
        reloadedVre.getCollections().values().forEach(col -> {
            List<PredicateInUse> predicatesFor = dataStoreOperations.getPredicatesFor(col);
            dataStoreOperations.addPropertiesToCollection(col, propertyFactory.fromPredicates(predicatesFor));
        });
    }
}
Also used : Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) PredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse)

Aggregations

PredicateInUse (nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse)9 ValueTypeInUse (nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse)5 Test (org.junit.Test)5 CreateCollection (nl.knaw.huygens.timbuctoo.core.dto.CreateCollection)4 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)4 CreateProperty (nl.knaw.huygens.timbuctoo.core.dto.rdf.CreateProperty)4 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)4 RdfProperty (nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty)3 VreStubs.minimalCorrectVre (nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre)3 Comparator.comparingInt (java.util.Comparator.comparingInt)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 Stack (java.util.Stack)2 Collectors.toCollection (java.util.stream.Collectors.toCollection)2 Collectors.toList (java.util.stream.Collectors.toList)2 RdfImportErrorReporter (nl.knaw.huygens.timbuctoo.core.RdfImportErrorReporter)2 ImmutableCreateProperty (nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableCreateProperty)2 ImmutablePredicateInUse (nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutablePredicateInUse)2 ImmutableValueTypeInUse (nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableValueTypeInUse)2