Search in sources :

Example 1 with StringToStringConverter

use of nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter in project timbuctoo by HuygensING.

the class LoadSaveCollectionTest method loadLoadsTheDisplayName.

@Test
public void loadLoadsTheDisplayName() {
    final Vertex collectionVertex = graph.addVertex(Collection.DATABASE_LABEL);
    final Vertex displayNameVertex = graph.addVertex(ReadableProperty.DATABASE_LABEL);
    final String collectionName = "persons";
    final String entityTypeName = "person";
    final String propertyType = new StringToStringConverter().getUniqueTypeIdentifier();
    collectionVertex.property(COLLECTION_NAME_PROPERTY_NAME, collectionName);
    collectionVertex.property(ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName);
    collectionVertex.property(IS_RELATION_COLLECTION_PROPERTY_NAME, false);
    displayNameVertex.property(LocalProperty.CLIENT_PROPERTY_NAME, "@displayName");
    displayNameVertex.property(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop1");
    displayNameVertex.property(LocalProperty.PROPERTY_TYPE_NAME, propertyType);
    collectionVertex.addEdge(HAS_DISPLAY_NAME_RELATION_NAME, displayNameVertex);
    final Collection instance = load(collectionVertex);
    assertThat(instance.getDisplayName(), instanceOf(ReadableProperty.class));
}
Also used : StringToStringConverter(nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ReadableProperty(nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) CollectionBuilder.timbuctooCollection(nl.knaw.huygens.timbuctoo.core.dto.dataset.CollectionBuilder.timbuctooCollection) Test(org.junit.Test)

Example 2 with StringToStringConverter

use of nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter in project timbuctoo by HuygensING.

the class LoadSaveCollectionTest method loadLoadsTheProperties.

@Test
public void loadLoadsTheProperties() {
    final Vertex collectionVertex = graph.addVertex(Collection.DATABASE_LABEL);
    final Vertex prop1Vertex = graph.addVertex(ReadableProperty.DATABASE_LABEL);
    final Vertex prop2Vertex = graph.addVertex(ReadableProperty.DATABASE_LABEL);
    final Vertex prop3Vertex = graph.addVertex(ReadableProperty.DATABASE_LABEL);
    final String collectionName = "persons";
    final String entityTypeName = "person";
    final String propertyType = new StringToStringConverter().getUniqueTypeIdentifier();
    collectionVertex.property(COLLECTION_NAME_PROPERTY_NAME, collectionName);
    collectionVertex.property(ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName);
    collectionVertex.property(IS_RELATION_COLLECTION_PROPERTY_NAME, false);
    prop1Vertex.property(LocalProperty.CLIENT_PROPERTY_NAME, "prop1");
    prop1Vertex.property(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop1");
    prop1Vertex.property(LocalProperty.PROPERTY_TYPE_NAME, propertyType);
    prop2Vertex.property(LocalProperty.CLIENT_PROPERTY_NAME, "prop2");
    prop2Vertex.property(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop2");
    prop2Vertex.property(LocalProperty.PROPERTY_TYPE_NAME, propertyType);
    prop3Vertex.property(LocalProperty.CLIENT_PROPERTY_NAME, "prop3");
    prop3Vertex.property(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop3");
    prop3Vertex.property(LocalProperty.PROPERTY_TYPE_NAME, "encoded-string-of-limited-values");
    prop3Vertex.property(LocalProperty.OPTIONS_PROPERTY_NAME, "[\"a\", \"b\"]");
    collectionVertex.addEdge(HAS_INITIAL_PROPERTY_RELATION_NAME, prop1Vertex);
    prop1Vertex.addEdge(LocalProperty.HAS_NEXT_PROPERTY_RELATION_NAME, prop2Vertex);
    prop2Vertex.addEdge(LocalProperty.HAS_NEXT_PROPERTY_RELATION_NAME, prop3Vertex);
    final Collection instance = load(collectionVertex);
    assertThat(instance.getWriteableProperties().keySet(), contains("prop1", "prop2", "prop3"));
    assertThat(instance.getWriteableProperties().values(), contains(instanceOf(ReadableProperty.class), instanceOf(ReadableProperty.class), instanceOf(ReadableProperty.class)));
}
Also used : StringToStringConverter(nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) CollectionBuilder.timbuctooCollection(nl.knaw.huygens.timbuctoo.core.dto.dataset.CollectionBuilder.timbuctooCollection) Test(org.junit.Test)

Example 3 with StringToStringConverter

use of nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter in project timbuctoo by HuygensING.

the class EntityTest method addPropertyAddsThePropertyToTheEntityForEachCollectionTheEntityIsConnectedTo.

@Test
public void addPropertyAddsThePropertyToTheEntityForEachCollectionTheEntityIsConnectedTo() {
    Vertex vertex = mock(Vertex.class);
    Collection collection1 = mock(Collection.class);
    Collection collection2 = mock(Collection.class);
    Entity entity = new Entity(vertex, Sets.newHashSet(collection1, collection2));
    String propName = "propName";
    String value = "value";
    entity.addProperty(propName, value, new StringToStringConverter().getUniqueTypeIdentifier());
    verify(collection1).addProperty(vertex, propName, value, type);
    verify(collection2).addProperty(vertex, propName, value, type);
}
Also used : StringToStringConverter(nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Test(org.junit.Test)

Aggregations

StringToStringConverter (nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter)3 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)3 Test (org.junit.Test)3 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)2 CollectionBuilder.timbuctooCollection (nl.knaw.huygens.timbuctoo.core.dto.dataset.CollectionBuilder.timbuctooCollection)2 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)2 ReadableProperty (nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty)1