use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsForMigrationsTest method itGIvesYouAnInitDb.
@Test
public void itGIvesYouAnInitDb() throws JsonProcessingException {
final TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations ops = forInitDb(graphManager);
assertThat(ops.databaseIsEmptyExceptForMigrations(), is(true));
ops.initDb(new VresBuilder().withVre("Admin", "", vre -> vre.withCollection("relations", CollectionBuilder::isRelationCollection)).build(), relationType("concept", "hasFirstPerson", "person", "someRel", false, false, false, UUID.randomUUID()));
assertThat(graphManager.getGraph().traversal().V().count().next(), is(4L));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deleteEntitySetsModified.
@Test
public void deleteEntitySetsModified() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
String idString = id.toString();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(idString).withProperty("isLatest", true).withVre("test").withType("thing").withProperty("rev", 1).withIncomingRelation("VERSION_OF", "orig")).withVertex("orig", v -> v.withTimId(idString).withVre("test").withType("thing").withProperty("isLatest", false).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
long timeStamp = Instant.now().toEpochMilli();
String userId = "userId";
instance.deleteEntity(collection, id, new Change(timeStamp, userId, null));
assertThat(graphManager.getGraph().traversal().V().has("tim_id", idString).has("deleted", true).next().value("modified"), sameJSONAs(String.format("{\"timeStamp\": %s,\"userId\": \"%s\"}", timeStamp, userId)));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityThrowsNotFoundIfTheEntityIsDeleted.
@Test(expected = NotFoundException.class)
public void getEntityThrowsNotFoundIfTheEntityIsDeleted() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withType("thing").withVre("test").withProperty("isLatest", true).withProperty("deleted", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deleteEntityIncreasesTheRevision.
// TODO move increase of the rev to TimbuctooActions
@Test
public void deleteEntityIncreasesTheRevision() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
String idString = id.toString();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(idString).withProperty("isLatest", true).withVre("test").withType("thing").withProperty("rev", 1).withIncomingRelation("VERSION_OF", "orig")).withVertex("orig", v -> v.withTimId(idString).withVre("test").withType("thing").withProperty("isLatest", false).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
int rev = instance.deleteEntity(collection, id, new Change(Instant.now().toEpochMilli(), "userId", null));
assertThat(rev, is(2));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method addPropertiesToCollectionsAddsPropertyDescriptionsToTheCollection.
@Test
public void addPropertiesToCollectionsAddsPropertyDescriptionsToTheCollection() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
vre = instance.loadVres().getVre("vre");
Collection collection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
ImmutableCreateProperty prop1 = ImmutableCreateProperty.builder().clientName("clientName1").propertyType("string").rdfUri("http://example.org/pred1").typeUri("http://example.org/string").build();
ImmutableCreateProperty prop2 = ImmutableCreateProperty.builder().clientName("clientName2").propertyType("string").rdfUri("http://example.org/pred2").typeUri("http://example.org/string").build();
instance.addPropertiesToCollection(collection, Lists.newArrayList(prop1, prop2));
collection = instance.loadVres().getCollectionForType(defaultEntityTypeName(vre)).get();
assertThat(collection.getReadableProperties().values(), hasSize(2));
List<Vertex> properties = graphManager.getGraph().traversal().V().hasLabel("property").toList();
assertThat(properties, containsInAnyOrder(likeVertex().withProperty("clientName", "@displayName"), likeVertex().withProperty("clientName", "clientName1").withProperty("dbName", collection.getEntityTypeName() + "_" + "http://example.org/pred1").withProperty("propertyType", "string").withProperty("rdfUri", "http://example.org/pred1").withProperty("typeUri", "http://example.org/string"), likeVertex().withProperty("clientName", "clientName2").withProperty("dbName", collection.getEntityTypeName() + "_" + "http://example.org/pred2").withProperty("propertyType", "string").withProperty("rdfUri", "http://example.org/pred2").withProperty("typeUri", "http://example.org/string")));
}
Aggregations