Search in sources :

Example 26 with Vre

use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.

the class LoadSaveVreTest method loadLoadsRelationCollections.

@Test
public void loadLoadsRelationCollections() {
    final String entityTypeName = "relation";
    final String collectionName = "relations";
    final Vre instance = load(initGraph(g -> g.withVertex("vre", v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName")).withVertex("collection", v -> v.withLabel(entityTypeName).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, collectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName).withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, true).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre"))));
    final Collection collectionByName = instance.getCollectionForCollectionName(collectionName).get();
    assertThat(instance.getRelationCollection().get(), equalTo(collectionByName));
}
Also used : TestGraphBuilder(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder) HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) Graph(org.apache.tinkerpop.gremlin.structure.Graph) Tuple(nl.knaw.huygens.timbuctoo.util.Tuple) HashMap(java.util.HashMap) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) VRE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.VRE_NAME_PROPERTY_NAME) Lists(com.google.common.collect.Lists) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataStoreOperations(nl.knaw.huygens.timbuctoo.core.DataStoreOperations) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Neo4jVertex(org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jVertex) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Maps(com.google.common.collect.Maps) KEYWORD_TYPES_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.KEYWORD_TYPES_PROPERTY_NAME) Consumer(java.util.function.Consumer) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) HAS_COLLECTION_RELATION_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_RELATION_NAME) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Optional(java.util.Optional) VreBuilder.vre(nl.knaw.huygens.timbuctoo.model.vre.VreBuilder.vre) Tuple.tuple(nl.knaw.huygens.timbuctoo.util.Tuple.tuple) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Test(org.junit.Test)

Example 27 with Vre

use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.

the class LoadSaveVreTest method loadLoadsInheritingCollections.

@Test
public void loadLoadsInheritingCollections() {
    final String entityTypeName = "wwperson";
    final String collectionName = "wwpersons";
    final String archetypeName = "person";
    final String archetypeCollectionName = "persons";
    final Vre instance = load(initGraph(g -> g.withVertex("vre", v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName")).withVertex("collection", v -> v.withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, collectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName).withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, false).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre")).withVertex("archetype", v -> v.withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, archetypeCollectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, archetypeName).withIncomingRelation(HAS_ARCHETYPE_RELATION_NAME, "collection"))));
    assertThat(instance.getImplementerOf("person").get().getEntityTypeName(), equalTo(entityTypeName));
}
Also used : TestGraphBuilder(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder) HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) Graph(org.apache.tinkerpop.gremlin.structure.Graph) Tuple(nl.knaw.huygens.timbuctoo.util.Tuple) HashMap(java.util.HashMap) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) VRE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.VRE_NAME_PROPERTY_NAME) Lists(com.google.common.collect.Lists) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataStoreOperations(nl.knaw.huygens.timbuctoo.core.DataStoreOperations) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Neo4jVertex(org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jVertex) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Maps(com.google.common.collect.Maps) KEYWORD_TYPES_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.KEYWORD_TYPES_PROPERTY_NAME) Consumer(java.util.function.Consumer) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) HAS_COLLECTION_RELATION_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_RELATION_NAME) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Optional(java.util.Optional) VreBuilder.vre(nl.knaw.huygens.timbuctoo.model.vre.VreBuilder.vre) Tuple.tuple(nl.knaw.huygens.timbuctoo.util.Tuple.tuple) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Test(org.junit.Test)

Example 28 with Vre

use of nl.knaw.huygens.timbuctoo.model.vre.Vre 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)

Example 29 with Vre

use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.

the class RdfImportSession method cleanImportSession.

static RdfImportSession cleanImportSession(String vreName, DataStoreOperations dataStoreOperations, RdfImportErrorReporter errorReporter, PropertyFactory propertyFactory, EntityFinisherHelper entityFinisherHelper) {
    Vre vre = dataStoreOperations.ensureVreExists(vreName);
    dataStoreOperations.clearMappingErrors(vre);
    dataStoreOperations.removeCollectionsAndEntities(vre);
    dataStoreOperations.addCollectionToVre(vre, CreateCollection.defaultCollection(vre.getVreName()));
    dataStoreOperations.addPredicateValueTypeVertexToVre(vre);
    Vre reloadedVre = dataStoreOperations.loadVres().getVre(vre.getVreName());
    return new RdfImportSession(dataStoreOperations, reloadedVre, errorReporter, propertyFactory, entityFinisherHelper);
}
Also used : Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre)

Example 30 with Vre

use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.

the class RdfImportSession method updateImportSession.

public static RdfImportSession updateImportSession(String vreName, DataStoreOperations dataStoreOperations, EntityFinisherHelper entityFinisherHelper) {
    LogRdfImportErrorReporter errorReporter = new LogRdfImportErrorReporter();
    Vre vre = dataStoreOperations.ensureVreExists(vreName);
    if (vre.getCollectionForTypeName(CreateCollection.defaultCollection(vreName).getEntityTypeName(vre)) == null) {
        dataStoreOperations.addCollectionToVre(vre, CreateCollection.defaultCollection(vre.getVreName()));
        dataStoreOperations.addPredicateValueTypeVertexToVre(vre);
    }
    Vre reloadedVre = dataStoreOperations.loadVres().getVre(vre.getVreName());
    return new RdfImportSession(dataStoreOperations, reloadedVre, errorReporter, new PropertyFactory(errorReporter), entityFinisherHelper);
}
Also used : PropertyFactory(nl.knaw.huygens.timbuctoo.core.rdf.PropertyFactory) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre)

Aggregations

Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)81 Test (org.junit.Test)71 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)48 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)46 VreStubs.minimalCorrectVre (nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre)44 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)43 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)41 Matchers.containsString (org.hamcrest.Matchers.containsString)35 List (java.util.List)34 Lists (com.google.common.collect.Lists)32 Optional (java.util.Optional)31 RdfProperty (nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty)31 CreateCollection (nl.knaw.huygens.timbuctoo.core.dto.CreateCollection)30 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)30 Direction (org.apache.tinkerpop.gremlin.structure.Direction)30 Graph (org.apache.tinkerpop.gremlin.structure.Graph)30 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)30 Matchers.contains (org.hamcrest.Matchers.contains)30 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)30 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)29