Search in sources :

Example 11 with COLLECTION_NAME_PROPERTY_NAME

use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.

the class DatabaseTest method findOrCreateCollectionAddsTheCollectionToItsArchetype.

@Test
public void findOrCreateCollectionAddsTheCollectionToItsArchetype() {
    String rdfUri = "http://www.example.com/entity";
    String localName = "entity";
    TinkerPopGraphManager graphWrapper = newGraph().withVertex(v -> v.withLabel(Vre.DATABASE_LABEL).withProperty("name", VRE_NAME)).withVertex(v -> {
        v.withLabel(Vre.DATABASE_LABEL);
        v.withProperty(Vre.VRE_NAME_PROPERTY_NAME, "Admin");
        v.withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "defaultArchetype");
    }).withVertex("defaultArchetype", v -> {
        v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept");
        v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts");
    }).wrap();
    Node collectionNode = mock(Node.class);
    when(collectionNode.getLocalName()).thenReturn(localName);
    when(collectionNode.getURI()).thenReturn(rdfUri);
    Database instance = new Database(graphWrapper);
    Collection collection = instance.findOrCreateCollection(VRE_NAME, collectionNode.getURI(), collectionNode.getLocalName());
    assertThat(collection, hasProperty("vreName", equalTo(VRE_NAME)));
    assertThat(graphWrapper.getGraph().traversal().V().hasLabel(DATABASE_LABEL).has(RDF_URI_PROP, rdfUri).out(HAS_ARCHETYPE_RELATION_NAME).hasNext(), is(true));
}
Also used : HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) LabelP(org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP) Matchers.not(org.hamcrest.Matchers.not) RDF_SYNONYM_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_SYNONYM_PROP) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) HAS_ENTITY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME) Matchers.hasSize(org.hamcrest.Matchers.hasSize) OptionalPresentMatcher.present(nl.knaw.huygens.hamcrest.OptionalPresentMatcher.present) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Before(org.junit.Before) HAS_ENTITY_NODE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) COLLECTION_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME) ENTITY_TYPE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Mockito.when(org.mockito.Mockito.when) T(org.apache.tinkerpop.gremlin.structure.T) DATABASE_LABEL(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL) List(java.util.List) Ignore(org.junit.Ignore) Node(org.apache.jena.graph.Node) RDF_URI_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_URI_PROP) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) Node(org.apache.jena.graph.Node) Test(org.junit.Test)

Example 12 with COLLECTION_NAME_PROPERTY_NAME

use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.

the class DatabaseTest method findOrCreateEntityGivesABlankNodeADefaultUri.

@Test
public void findOrCreateEntityGivesABlankNodeADefaultUri() {
    TinkerPopGraphManager graphWrapper = newGraph().withVertex(v -> v.withLabel(Vre.DATABASE_LABEL).withProperty("name", VRE_NAME)).withVertex(v -> {
        v.withLabel(Vre.DATABASE_LABEL);
        v.withProperty(Vre.VRE_NAME_PROPERTY_NAME, "Admin");
        v.withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "defaultArchetype");
    }).withVertex("defaultArchetype", v -> {
        v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept");
        v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts");
        v.withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityCollection");
    }).withVertex("entityCollection", v -> {
    }).wrap();
    final Database instance = new Database(graphWrapper, modifier);
    Node blankNode = TripleCreator.createBlankNode();
    String expectedUri = VRE_NAME + ":" + blankNode.getBlankNodeLabel();
    Entity entity = instance.findOrCreateEntity(VRE_NAME, blankNode);
    assertThat(entity, is(notNullValue()));
    assertThat(entity.vertex.value(RDF_SYNONYM_PROP), is(new String[] { expectedUri }));
}
Also used : HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) LabelP(org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP) Matchers.not(org.hamcrest.Matchers.not) RDF_SYNONYM_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_SYNONYM_PROP) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) HAS_ENTITY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME) Matchers.hasSize(org.hamcrest.Matchers.hasSize) OptionalPresentMatcher.present(nl.knaw.huygens.hamcrest.OptionalPresentMatcher.present) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Before(org.junit.Before) HAS_ENTITY_NODE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) COLLECTION_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME) ENTITY_TYPE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Mockito.when(org.mockito.Mockito.when) T(org.apache.tinkerpop.gremlin.structure.T) DATABASE_LABEL(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL) List(java.util.List) Ignore(org.junit.Ignore) Node(org.apache.jena.graph.Node) RDF_URI_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_URI_PROP) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) Node(org.apache.jena.graph.Node) Test(org.junit.Test)

Example 13 with COLLECTION_NAME_PROPERTY_NAME

use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.

the class DatabaseTest method findEntitiesByCollectionReturnsAllTheEntitiesOfTheCollection.

@Test
public void findEntitiesByCollectionReturnsAllTheEntitiesOfTheCollection() {
    CollectionDescription desc = CollectionDescription.createCollectionDescription("collection", VRE_NAME);
    TinkerPopGraphManager graphWrapper = newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, desc.getEntityTypeName()).withProperty(COLLECTION_NAME_PROPERTY_NAME, desc.getCollectionName()).withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityVertex")).withVertex("entityVertex", v -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity1").withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity2")).withVertex("entity1", v -> {
    }).withVertex("entity2", v -> {
    }).withVertex("entityOfOtherCollection", v -> {
    }).wrap();
    Database instance = new Database(graphWrapper);
    Collection collection = mock(Collection.class);
    when(collection.getDescription()).thenReturn(desc);
    Set<Entity> entitiesByCollection = instance.findEntitiesByCollection(collection);
    assertThat(entitiesByCollection, hasSize(2));
}
Also used : HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) LabelP(org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP) Matchers.not(org.hamcrest.Matchers.not) RDF_SYNONYM_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_SYNONYM_PROP) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) HAS_ENTITY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME) Matchers.hasSize(org.hamcrest.Matchers.hasSize) OptionalPresentMatcher.present(nl.knaw.huygens.hamcrest.OptionalPresentMatcher.present) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Before(org.junit.Before) HAS_ENTITY_NODE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) COLLECTION_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME) ENTITY_TYPE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Mockito.when(org.mockito.Mockito.when) T(org.apache.tinkerpop.gremlin.structure.T) DATABASE_LABEL(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL) List(java.util.List) Ignore(org.junit.Ignore) Node(org.apache.jena.graph.Node) RDF_URI_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_URI_PROP) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) Test(org.junit.Test)

Example 14 with COLLECTION_NAME_PROPERTY_NAME

use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.

the class TinkerPopOperations method retrieveProperty.

@Override
public Optional<RdfReadProperty> retrieveProperty(Vre vre, String entityRdfUri, String propertyUri) {
    Optional<Vertex> entityOpt = indexHandler.findVertexInRdfIndex(vre, entityRdfUri);
    if (entityOpt.isPresent()) {
        Vertex entity = entityOpt.get();
        Iterable<Vertex> collectionOfEntity = () -> collectionsFor(entity);
        Optional<Collection> colOpt = StreamSupport.stream(collectionOfEntity.spliterator(), false).map(col -> getProp(col, COLLECTION_NAME_PROPERTY_NAME, String.class)).filter(colNameProp -> colNameProp.isPresent()).map(colNameProp -> colNameProp.get()).map(vre::getCollectionForCollectionName).filter(Optional::isPresent).map(Optional::get).findFirst();
        if (colOpt.isPresent()) {
            Collection collection = colOpt.get();
            VertexProperty<String> property = entity.property(createPropName(collection.getEntityTypeName(), propertyUri));
            if (property.isPresent()) {
                return Optional.of(new RdfReadProperty(propertyUri, property.value()));
            }
        }
    }
    return Optional.empty();
}
Also used : AlreadyUpdatedException(nl.knaw.huygens.timbuctoo.core.AlreadyUpdatedException) CreateCollection(nl.knaw.huygens.timbuctoo.core.dto.CreateCollection) RdfImportedDefaultDisplayname(nl.knaw.huygens.timbuctoo.model.properties.RdfImportedDefaultDisplayname) VRE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.VRE_NAME_PROPERTY_NAME) EdgeManipulator.duplicateEdge(nl.knaw.huygens.timbuctoo.database.tinkerpop.EdgeManipulator.duplicateEdge) MediaType(javax.ws.rs.core.MediaType) QuickSearch(nl.knaw.huygens.timbuctoo.core.dto.QuickSearch) ReadableProperty(nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty) RdfProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty) COLLECTION_IS_UNKNOWN_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_IS_UNKNOWN_PROPERTY_NAME) Map(java.util.Map) Converters.arrayToEncodedArray(nl.knaw.huygens.timbuctoo.model.properties.converters.Converters.arrayToEncodedArray) JsonNode(com.fasterxml.jackson.databind.JsonNode) DataStoreOperations(nl.knaw.huygens.timbuctoo.core.DataStoreOperations) Transaction(org.apache.tinkerpop.gremlin.structure.Transaction) HAS_ENTITY_NODE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME) QuickSearchResult(nl.knaw.huygens.timbuctoo.core.dto.QuickSearchResult) RdfIndexChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.RdfIndexChangeListener) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) COLLECTION_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME) Logmarkers.configurationFailure(nl.knaw.huygens.timbuctoo.logging.Logmarkers.configurationFailure) Set(java.util.Set) ChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.ChangeListener) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ImmutableValueTypeInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableValueTypeInUse) ReadEntity(nl.knaw.huygens.timbuctoo.core.dto.ReadEntity) DATABASE_LABEL(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL) Element(org.apache.tinkerpop.gremlin.structure.Element) Stream(java.util.stream.Stream) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) CreateEntity(nl.knaw.huygens.timbuctoo.core.dto.CreateEntity) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Index(org.neo4j.graphdb.index.Index) ERROR_PREFIX(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver.ERROR_PREFIX) LocalProperty(nl.knaw.huygens.timbuctoo.model.properties.LocalProperty) LabelP(org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP) RAW_PROPERTY_EDGE_NAME(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver.RAW_PROPERTY_EDGE_NAME) CreateProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.CreateProperty) Supplier(java.util.function.Supplier) Node(org.neo4j.graphdb.Node) CreateRelation(nl.knaw.huygens.timbuctoo.core.dto.CreateRelation) Lists(com.google.common.collect.Lists) ImmutableVresDto(nl.knaw.huygens.timbuctoo.core.dto.dataset.ImmutableVresDto) PersonNames(nl.knaw.huygens.timbuctoo.model.PersonNames) HAS_ENTITY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME) StreamSupport(java.util.stream.StreamSupport) PropertyDescriptorFactory(nl.knaw.huygens.timbuctoo.search.description.property.PropertyDescriptorFactory) RelationType(nl.knaw.huygens.timbuctoo.core.dto.RelationType) Logmarkers.databaseInvariant(nl.knaw.huygens.timbuctoo.logging.Logmarkers.databaseInvariant) RelationTypeService(nl.knaw.huygens.timbuctoo.relationtypes.RelationTypeService) AddLabelChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.AddLabelChangeListener) VreBuilder(nl.knaw.huygens.timbuctoo.model.vre.VreBuilder) DataStream(nl.knaw.huygens.timbuctoo.core.dto.DataStream) ImmutablePredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutablePredicateInUse) IOException(java.io.IOException) T(org.apache.tinkerpop.gremlin.structure.T) HAS_NEXT_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty.HAS_NEXT_PROPERTY_RELATION_NAME) DatabaseMigrator(nl.knaw.huygens.timbuctoo.server.databasemigration.DatabaseMigrator) Direction(org.apache.tinkerpop.gremlin.structure.Direction) VertexDuplicator.duplicateVertex(nl.knaw.huygens.timbuctoo.database.tinkerpop.VertexDuplicator.duplicateVertex) CompositeChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.CompositeChangeListener) HAS_DISPLAY_NAME_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_DISPLAY_NAME_RELATION_NAME) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) TinkerPopPropertyConverter(nl.knaw.huygens.timbuctoo.database.tinkerpop.conversion.TinkerPopPropertyConverter) GraphReadUtils.getProp(nl.knaw.huygens.timbuctoo.model.GraphReadUtils.getProp) Change(nl.knaw.huygens.timbuctoo.model.Change) WwDocumentDisplayNameDescriptor(nl.knaw.huygens.timbuctoo.search.description.property.WwDocumentDisplayNameDescriptor) RDFINDEX_NAME(nl.knaw.huygens.timbuctoo.rdf.Database.RDFINDEX_NAME) ImmutableEntityRelation(nl.knaw.huygens.timbuctoo.core.dto.ImmutableEntityRelation) StreamIterator.stream(nl.knaw.huygens.timbuctoo.util.StreamIterator.stream) HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) Graph(org.apache.tinkerpop.gremlin.structure.Graph) LoggerFactory(org.slf4j.LoggerFactory) RDF_SYNONYM_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_SYNONYM_PROP) PropertyParserFactory(nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory) EntityRelation(nl.knaw.huygens.timbuctoo.core.dto.EntityRelation) TinkerPopToEntityMapper(nl.knaw.huygens.timbuctoo.database.tinkerpop.conversion.TinkerPopToEntityMapper) RelationNotPossibleException(nl.knaw.huygens.timbuctoo.core.RelationNotPossibleException) URI(java.net.URI) P(org.apache.tinkerpop.gremlin.process.traversal.P) Property(org.apache.tinkerpop.gremlin.structure.Property) IS_RELATION_COLLECTION_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.IS_RELATION_COLLECTION_PROPERTY_NAME) CollectionHasEntityRelationChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.CollectionHasEntityRelationChangeListener) org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has) ImmutableMap(com.google.common.collect.ImmutableMap) CollectionBuilder(nl.knaw.huygens.timbuctoo.core.dto.dataset.CollectionBuilder) EntityFinisherHelper(nl.knaw.huygens.timbuctoo.core.EntityFinisherHelper) LocationNames(nl.knaw.huygens.timbuctoo.model.LocationNames) NotFoundException(nl.knaw.huygens.timbuctoo.core.NotFoundException) UUID(java.util.UUID) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) UpdateEntity(nl.knaw.huygens.timbuctoo.core.dto.UpdateEntity) List(java.util.List) DirectionalRelationType(nl.knaw.huygens.timbuctoo.core.dto.DirectionalRelationType) Optional(java.util.Optional) FulltextIndexChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.FulltextIndexChangeListener) JsonBuilder.jsnO(nl.knaw.huygens.timbuctoo.util.JsonBuilder.jsnO) HAS_PREDICATE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_PREDICATE_RELATION_NAME) Tuple(nl.knaw.huygens.timbuctoo.util.Tuple) HashMap(java.util.HashMap) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Function(java.util.function.Function) VERSION_OF(nl.knaw.huygens.timbuctoo.database.tinkerpop.VertexDuplicator.VERSION_OF) VreMetadata(nl.knaw.huygens.timbuctoo.model.vre.VreMetadata) Logmarkers(nl.knaw.huygens.timbuctoo.logging.Logmarkers) CollectionNameHelper.defaultEntityTypeName(nl.knaw.huygens.timbuctoo.core.CollectionNameHelper.defaultEntityTypeName) VertexProperty(org.apache.tinkerpop.gremlin.structure.VertexProperty) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) SAVED_MAPPING_STATE(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver.SAVED_MAPPING_STATE) HAS_INITIAL_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_INITIAL_PROPERTY_RELATION_NAME) JsonBuilder.jsnA(nl.knaw.huygens.timbuctoo.util.JsonBuilder.jsnA) COLLECTION_ENTITIES_LABEL(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_ENTITIES_LABEL) NoSuchElementException(java.util.NoSuchElementException) JsonBuilder.jsn(nl.knaw.huygens.timbuctoo.util.JsonBuilder.jsn) Edge(org.apache.tinkerpop.gremlin.structure.Edge) RdfReadProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty) PredicateInUse(nl.knaw.huygens.timbuctoo.core.dto.rdf.PredicateInUse) Logger(org.slf4j.Logger) TimProperty(nl.knaw.huygens.timbuctoo.core.dto.property.TimProperty) Iterator(java.util.Iterator) RAW_ITEM_EDGE_NAME(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver.RAW_ITEM_EDGE_NAME) ENTITY_TYPE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME) PropertyDescriptor(nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor) org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__) TempName(nl.knaw.huygens.timbuctoo.model.TempName) Maps(com.google.common.collect.Maps) IdIndexChangeListener(nl.knaw.huygens.timbuctoo.database.tinkerpop.changelistener.IdIndexChangeListener) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) PropertyNameHelper.createPropName(nl.knaw.huygens.timbuctoo.database.tinkerpop.PropertyNameHelper.createPropName) TIMBUCTOO_NAMESPACE(nl.knaw.huygens.timbuctoo.server.databasemigration.RelationTypeRdfUriMigration.TIMBUCTOO_NAMESPACE) Vres(nl.knaw.huygens.timbuctoo.model.vre.Vres) SystemPropertyModifier(nl.knaw.huygens.timbuctoo.rdf.SystemPropertyModifier) Collectors.toList(java.util.stream.Collectors.toList) HAS_COLLECTION_RELATION_NAME(nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_RELATION_NAME) Clock(java.time.Clock) HAS_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_PROPERTY_RELATION_NAME) RAW_COLLECTION_EDGE_NAME(nl.knaw.huygens.timbuctoo.database.tinkerpop.TinkerpopSaver.RAW_COLLECTION_EDGE_NAME) UpdateRelation(nl.knaw.huygens.timbuctoo.core.dto.UpdateRelation) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexDuplicator.duplicateVertex(nl.knaw.huygens.timbuctoo.database.tinkerpop.VertexDuplicator.duplicateVertex) Optional(java.util.Optional) RdfReadProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfReadProperty) CreateCollection(nl.knaw.huygens.timbuctoo.core.dto.CreateCollection) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)

Example 15 with COLLECTION_NAME_PROPERTY_NAME

use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.

the class LoadSaveCollectionTest method saveThrowsWhenTheCollectionNameIsNotUniqueToThisVre.

@Test(expected = IllegalArgumentException.class)
public void saveThrowsWhenTheCollectionNameIsNotUniqueToThisVre() {
    Graph graph = newGraph().withVertex(v -> {
        v.withLabel(Collection.DATABASE_LABEL).withProperty(COLLECTION_NAME_PROPERTY_NAME, "persons").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "person").withIncomingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "vre");
    }).withVertex("vre", v -> {
        v.withLabel(Vre.DATABASE_LABEL).withProperty(Vre.VRE_NAME_PROPERTY_NAME, "OtherVreName");
    }).build();
    save(new Collection("person", "person", null, Maps.newLinkedHashMap(), "persons", new Vre(vreName), null, false, false, null), graph);
}
Also used : HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) LocalProperty(nl.knaw.huygens.timbuctoo.model.properties.LocalProperty) PropertyTypes.localProperty(nl.knaw.huygens.timbuctoo.model.properties.PropertyTypes.localProperty) Graph(org.apache.tinkerpop.gremlin.structure.Graph) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Lists(com.google.common.collect.Lists) ReadableProperty(nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty) HAS_INITIAL_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_INITIAL_PROPERTY_RELATION_NAME) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) StringToStringConverter(nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter) IS_RELATION_COLLECTION_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.IS_RELATION_COLLECTION_PROPERTY_NAME) CollectionBuilder.timbuctooCollection(nl.knaw.huygens.timbuctoo.core.dto.dataset.CollectionBuilder.timbuctooCollection) COLLECTION_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME) ENTITY_TYPE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Maps(com.google.common.collect.Maps) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) DATABASE_LABEL(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) HAS_DISPLAY_NAME_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_DISPLAY_NAME_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) HAS_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_PROPERTY_RELATION_NAME) Graph(org.apache.tinkerpop.gremlin.structure.Graph) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) CollectionBuilder.timbuctooCollection(nl.knaw.huygens.timbuctoo.core.dto.dataset.CollectionBuilder.timbuctooCollection) Test(org.junit.Test)

Aggregations

COLLECTION_NAME_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME)24 ENTITY_TYPE_NAME_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME)24 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)24 DATABASE_LABEL (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL)23 HAS_ARCHETYPE_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME)23 HAS_ENTITY_NODE_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME)23 HAS_ENTITY_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME)23 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)23 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)23 LabelP (org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP)23 T (org.apache.tinkerpop.gremlin.structure.T)23 Matchers.equalTo (org.hamcrest.Matchers.equalTo)23 Test (org.junit.Test)23 RDF_URI_PROP (nl.knaw.huygens.timbuctoo.rdf.Database.RDF_URI_PROP)22 Matchers.is (org.hamcrest.Matchers.is)22 Matchers.not (org.hamcrest.Matchers.not)22 Mockito.mock (org.mockito.Mockito.mock)22 Mockito.when (org.mockito.Mockito.when)22 HAS_DISPLAY_NAME_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_DISPLAY_NAME_RELATION_NAME)16 HAS_PROPERTY_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_PROPERTY_RELATION_NAME)16