Search in sources :

Example 36 with ReadEntity

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

the class TripleImporterIntegrationTest method importTripleShouldConnectTheSubjectEntityToTheCollectionNamedByTheObject.

@Test
public void importTripleShouldConnectTheSubjectEntityToTheCollectionNamedByTheObject() throws Exception {
    final Triple abadan = createTripleIterator(ABADAN_HAS_TYPE_FEATURE_TRIPLE).next();
    instance.importTriple(true, abadan);
    rdfImportSession.commit();
    rdfImportSession.close();
    Optional<ReadEntity> readEntity = getReadEntity(COLLECTION_NAME, ABADAN_URI);
    assertThat(readEntity, is(present()));
}
Also used : Triple(org.apache.jena.graph.Triple) TripleCreator.createSingleTriple(nl.knaw.huygens.timbuctoo.rdf.TripleCreator.createSingleTriple) ReadEntity(nl.knaw.huygens.timbuctoo.core.dto.ReadEntity) Test(org.junit.Test)

Example 37 with ReadEntity

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

the class TripleImporterIntegrationTest method importTripleShouldMapToARelationBetweenTheSubjectAndAnExistingObjectVertex.

@Test
public void importTripleShouldMapToARelationBetweenTheSubjectAndAnExistingObjectVertex() throws Exception {
    final Triple abadan = createTripleIterator(ABADAN_POINT_TRIPLE).next();
    final Triple iran = createTripleIterator(IRAN_POINT_TRIPLE).next();
    final Triple relation = createTripleIterator(ABADAN_IS_PART_OF_IRAN_TRIPLE).next();
    instance.importTriple(true, abadan);
    instance.importTriple(true, iran);
    instance.importTriple(true, relation);
    rdfImportSession.commit();
    rdfImportSession.close();
    Collection collectionMetadata = timbuctooActions.getCollectionMetadata(DEFAULT_COLLECTION_NAME);
    DataStream<ReadEntity> result = timbuctooActions.getCollection(collectionMetadata, 0, 10, false, (entity, entityVertex) -> {
    }, (traversalSource, vre, target, relationRef) -> {
    });
    assertThat(result.map(readEntity -> readEntity), hasSize(2));
}
Also used : Triple(org.apache.jena.graph.Triple) TripleCreator.createSingleTriple(nl.knaw.huygens.timbuctoo.rdf.TripleCreator.createSingleTriple) ReadEntity(nl.knaw.huygens.timbuctoo.core.dto.ReadEntity) TripleCreator.createTripleIterator(nl.knaw.huygens.timbuctoo.rdf.TripleCreator.createTripleIterator) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) RdfImportSession(nl.knaw.huygens.timbuctoo.core.RdfImportSession) TimbuctooActionsStubs(nl.knaw.huygens.timbuctoo.core.TimbuctooActionsStubs) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) TripleCreator.createSingleTripleWithLiteralObject(nl.knaw.huygens.timbuctoo.rdf.TripleCreator.createSingleTripleWithLiteralObject) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) VresBuilder(nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder) TimbuctooActions(nl.knaw.huygens.timbuctoo.core.TimbuctooActions) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) Matchers.hasSize(org.hamcrest.Matchers.hasSize) OptionalPresentMatcher.present(nl.knaw.huygens.hamcrest.OptionalPresentMatcher.present) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) RelationType(nl.knaw.huygens.timbuctoo.core.dto.RelationType) CollectionNameHelper(nl.knaw.huygens.timbuctoo.core.CollectionNameHelper) TinkerPopOperations(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerPopOperations) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) DataStream(nl.knaw.huygens.timbuctoo.core.dto.DataStream) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) CollectionBuilder(nl.knaw.huygens.timbuctoo.core.dto.dataset.CollectionBuilder) EntityFinisherHelper(nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper) Triple(org.apache.jena.graph.Triple) TripleCreator.createSingleTriple(nl.knaw.huygens.timbuctoo.rdf.TripleCreator.createSingleTriple) Test(org.junit.Test) Vres(nl.knaw.huygens.timbuctoo.model.vre.Vres) ReadEntity(nl.knaw.huygens.timbuctoo.core.dto.ReadEntity) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Optional(java.util.Optional) ExtendedIterator(org.apache.jena.util.iterator.ExtendedIterator) Matchers.is(org.hamcrest.Matchers.is) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Test(org.junit.Test)

Aggregations

ReadEntity (nl.knaw.huygens.timbuctoo.core.dto.ReadEntity)37 Test (org.junit.Test)30 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)28 Vres (nl.knaw.huygens.timbuctoo.model.vre.Vres)26 IOException (java.io.IOException)25 List (java.util.List)25 UUID (java.util.UUID)25 Optional (java.util.Optional)24 TimProperty (nl.knaw.huygens.timbuctoo.core.dto.property.TimProperty)24 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)23 URI (java.net.URI)23 NotFoundException (nl.knaw.huygens.timbuctoo.core.NotFoundException)23 DataStream (nl.knaw.huygens.timbuctoo.core.dto.DataStream)23 Change (nl.knaw.huygens.timbuctoo.model.Change)23 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)23 JsonBuilder.jsn (nl.knaw.huygens.timbuctoo.util.JsonBuilder.jsn)23 JsonBuilder.jsnO (nl.knaw.huygens.timbuctoo.util.JsonBuilder.jsnO)23 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)22 Lists (com.google.common.collect.Lists)22