use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class D3GraphGeneratorService method loadLinks.
private void loadLinks(String relationTypeName, String vreId, D3Graph d3Graph, List<String> relationNames, int depth, int currentDepth, Edge edge) {
Vertex source = edge.inVertex();
Vertex target = edge.outVertex();
final Optional<Collection> sourceCollection = GraphReadUtils.getCollectionByVreId(source, mappings, vreId);
final Optional<Collection> targetCollection = GraphReadUtils.getCollectionByVreId(target, mappings, vreId);
if (sourceCollection.isPresent() && targetCollection.isPresent()) {
final String sourceEntityTypeName = sourceCollection.get().getEntityTypeName();
final String targetEntityTypeName = targetCollection.get().getEntityTypeName();
d3Graph.addNode(source, sourceEntityTypeName);
d3Graph.addNode(target, targetEntityTypeName);
d3Graph.addLink(edge, source, target, sourceEntityTypeName, targetEntityTypeName);
if (currentDepth < depth) {
generateD3Graph(relationTypeName, vreId, d3Graph, source, relationNames, depth, currentDepth + 1);
generateD3Graph(relationTypeName, vreId, d3Graph, target, relationNames, depth, currentDepth + 1);
}
}
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class TimbuctooActionsGetTest method getCollectionMetadataReturnsTheCollectionThatIsRequested.
@Test
public void getCollectionMetadataReturnsTheCollectionThatIsRequested() throws Exception {
when(dataStoreOperations.loadVres()).thenReturn(vresWithCollection("knowncollections"));
Collection knownCollection = instance.getCollectionMetadata("knowncollections");
assertThat(knownCollection.getCollectionName(), is("knowncollections"));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection 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.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityByRdfUriReturnsAnEmptyOptionalIfTheEntityCannotBeFound.
@Test
public void getEntityByRdfUriReturnsAnEmptyOptionalIfTheEntityCannotBeFound() {
Vres vres = createConfiguration();
TinkerPopOperations instance = forGraphWrapperAndMappings(newGraph().wrap(), vres);
Collection collection = vres.getCollection("testthings").get();
Optional<ReadEntity> readEntity = instance.getEntityByRdfUri(collection, "http://example.com/entity", false);
assertThat(readEntity, is(not(present())));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection 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) -> {
});
}
Aggregations