use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME 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));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME in project timbuctoo by HuygensING.
the class CollectionTest method setArchetypeConnectsTheCollectionToTheNewArchetype.
@Test
public void setArchetypeConnectsTheCollectionToTheNewArchetype() {
String newArchetypeEntity = "newArchetype";
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
Vertex archetypeVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity).next();
Collection archetype = new Collection("", archetypeVertex, graphWrapper);
instance.setArchetype(archetype, "");
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_ARCHETYPE_RELATION_NAME).toList(), hasItem(likeVertex().withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity)));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_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));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME in project timbuctoo by HuygensING.
the class CollectionTest method setArchetypeSetsTheUriOfTheOriginalArchetypeToEdgeToTheArchetype.
@Test
public void setArchetypeSetsTheUriOfTheOriginalArchetypeToEdgeToTheArchetype() {
String newArchetypeEntity = "newArchetype";
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
Vertex archetypeVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity).next();
Collection archetype = new Collection("", archetypeVertex, graphWrapper);
String originalArchetypeUri = "http://example.com/originalArchetype";
instance.setArchetype(archetype, originalArchetypeUri);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).outE(HAS_ARCHETYPE_RELATION_NAME).toList(), hasItem(likeEdge().withProperty(RDF_URI_PROP, originalArchetypeUri)));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME in project timbuctoo by HuygensING.
the class DatabaseTest method findOrCreateCollectionReturnsTheCollectionForARequestedVre.
@Test
public void findOrCreateCollectionReturnsTheCollectionForARequestedVre() {
String vreName = "vreName";
String rdfUri = "http://www.example.com/entity";
String localName = "entity";
TinkerPopGraphManager graphWrapper = newGraph().withVertex(v -> v.withLabel(Vre.DATABASE_LABEL).withProperty("name", vreName).withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "collection")).withVertex("collection", v -> v.withLabel("collection").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, localName)).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.withIncomingRelation(HAS_ARCHETYPE_RELATION_NAME, "collection");
}).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(vreName, collectionNode.getURI(), collectionNode.getLocalName());
assertThat(collection, hasProperty("vreName", equalTo(vreName)));
}
Aggregations