Search in sources :

Example 1 with KEYWORD_TYPES_PROPERTY_NAME

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

the class LoadSaveVreTest method loadLoadsTheCollections.

@Test
public void loadLoadsTheCollections() throws JsonProcessingException {
    final String entityTypeName = "person";
    final String collectionName = "persons";
    final HashMap<String, String> keywordTypes = new HashMap<>();
    keywordTypes.put("keyword", "type");
    String stringifiedKeyWordTypes = new ObjectMapper().writeValueAsString(keywordTypes);
    final Vre instance = load(initGraph(g -> g.withVertex("vre", v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName").withProperty(KEYWORD_TYPES_PROPERTY_NAME, stringifiedKeyWordTypes)).withVertex(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, false).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre"))));
    final Collection collectionByName = instance.getCollectionForCollectionName(collectionName).get();
    assertThat(instance.getKeywordTypes().get("keyword"), equalTo("type"));
    assertThat(collectionByName, instanceOf(Collection.class));
    assertThat(instance.getCollectionForTypeName(entityTypeName), instanceOf(Collection.class));
    assertThat(instance.getCollections().get(entityTypeName), instanceOf(Collection.class));
    assertThat(instance.getEntityTypes(), contains(entityTypeName));
    assertThat(instance.getImplementerOf("person").get(), equalTo(collectionByName));
    assertThat(instance.getOwnType("notmytype", "person"), 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) HashMap(java.util.HashMap) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with KEYWORD_TYPES_PROPERTY_NAME

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

the class LoadSaveVreTest method loadLoadsAVreFromAVertex.

@Test
public void loadLoadsAVreFromAVertex() throws JsonProcessingException {
    final Map<String, String> keyWordTypes = new HashMap<>();
    keyWordTypes.put("keyword", "type");
    String stringifiedKeyWordTypes = new ObjectMapper().writeValueAsString(keyWordTypes);
    final Vre instance = load(initGraph(g -> g.withVertex(v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName").withProperty(KEYWORD_TYPES_PROPERTY_NAME, stringifiedKeyWordTypes))));
    assertThat(instance.getVreName(), equalTo("VreName"));
    assertThat(instance.getKeywordTypes().get("keyword"), equalTo("type"));
}
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) HashMap(java.util.HashMap) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Consumer (java.util.function.Consumer)2 DataStoreOperations (nl.knaw.huygens.timbuctoo.core.DataStoreOperations)2 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)2 HAS_ARCHETYPE_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME)2 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)2 HAS_COLLECTION_RELATION_NAME (nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_RELATION_NAME)2 KEYWORD_TYPES_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.model.vre.Vre.KEYWORD_TYPES_PROPERTY_NAME)2 VRE_NAME_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.model.vre.Vre.VRE_NAME_PROPERTY_NAME)2 VreBuilder.vre (nl.knaw.huygens.timbuctoo.model.vre.VreBuilder.vre)2 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)2 TestGraphBuilder (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder)2 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)2