use of nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_RELATION_NAME in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deleteVreRemovesAllTheVresCollectionsFromDatabase.
@Test
public void deleteVreRemovesAllTheVresCollectionsFromDatabase() {
TinkerPopGraphManager graphManager = newGraph().withVertex("vreName", v -> v.withLabel("VRE").withProperty(Vre.VRE_NAME_PROPERTY_NAME, "vreName").withOutgoingRelation(HAS_COLLECTION_RELATION_NAME, "collection1").withOutgoingRelation(HAS_COLLECTION_RELATION_NAME, "collection2")).withVertex("collection1", v -> v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "collection1").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "entityType1").withProperty(IS_RELATION_COLLECTION_PROPERTY_NAME, true).withOutgoingRelation(HAS_DISPLAY_NAME_RELATION_NAME, "displayName").withOutgoingRelation(HAS_PROPERTY_RELATION_NAME, "property").withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode")).withVertex("displayName", v -> v.withProperty("displayName", true).withProperty("propertyType", "string")).withVertex("property", v -> v.withProperty("property", true).withProperty("propertyType", "string")).withVertex("entityNode", v -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity")).withVertex("entity", v -> v.withProperty("entity", true)).withVertex("collection2", v -> v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "collection2").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "entityType2").withProperty(IS_RELATION_COLLECTION_PROPERTY_NAME, false)).withVertex("otherVreCollection", v -> v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "otherVreCollection").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "entityType3").withProperty(IS_RELATION_COLLECTION_PROPERTY_NAME, false)).wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
instance.deleteVre("vreName");
Graph graph = graphManager.getGraph();
assertThat(graph.traversal().V().has(Vre.VRE_NAME_PROPERTY_NAME, "vreName").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has(COLLECTION_NAME_PROPERTY_NAME, "collection1").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has(COLLECTION_NAME_PROPERTY_NAME, "collection2").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has(COLLECTION_NAME_PROPERTY_NAME, "otherVreCollection").hasNext(), equalTo(true));
assertThat(graph.traversal().V().has("entity").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has("displayName").hasNext(), equalTo(false));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_RELATION_NAME in project timbuctoo by HuygensING.
the class LoadSaveVreTest method loadLoadsRelationCollections.
@Test
public void loadLoadsRelationCollections() {
final String entityTypeName = "relation";
final String collectionName = "relations";
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(entityTypeName).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, collectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName).withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, true).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre"))));
final Collection collectionByName = instance.getCollectionForCollectionName(collectionName).get();
assertThat(instance.getRelationCollection().get(), equalTo(collectionByName));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_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.model.vre.Vre.HAS_COLLECTION_RELATION_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));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre.HAS_COLLECTION_RELATION_NAME in project timbuctoo by HuygensING.
the class LoadSaveVreTest method saveAddsVreCollectionsToTheVre.
@Test
public void saveAddsVreCollectionsToTheVre() {
Vre vre = vre("VreName", "prefix").withCollection("prefixpersons").withCollection("prefixdocuments").build();
Optional<Vertex> vreVertex = save(vre, initGraph()).stream().filter(x -> ((Neo4jVertex) x).labels().contains(Vre.DATABASE_LABEL)).findAny();
if (!vreVertex.isPresent()) {
throw new RuntimeException("No Vre vertex found!");
} else {
List<Vertex> edges = Lists.newArrayList(vreVertex.get().vertices(Direction.OUT, HAS_COLLECTION_RELATION_NAME));
assertThat(edges, containsInAnyOrder(likeVertex().withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, "prefixpersons"), likeVertex().withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, "prefixdocuments")));
}
}
Aggregations