@Test public void getCollectionReturnsRelationsIfRequested() { Vres vres = createConfiguration(); Collection collection = vres.getCollection("testthings").get(); UUID thingId = UUID.randomUUID(); UUID stuffId = UUID.randomUUID(); TinkerPopGraphManager graphManager = newGraph() .withVertex("v1", v -> v .withLabel("testthing") .withVre("test") .withType("thing") .isLatest(true) .withTimId(thingId.toString()) .withOutgoingRelation("isCreatorOf", "stuff") ) .withVertex("stuff", v -> v .withVre("test") .withType("stuff") .withTimId(stuffId.toString()) ) .withVertex(v -> v .withProperty("relationtype_regularName", "isCreatedBy") .withProperty("relationtype_inverseName", "isCreatorOf") ) .wrap(); TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres); DataStream<ReadEntity> entities = instance.getCollection(collection, 0, 1, true, (readEntity, vertex) -> { }, (graphTraversalSource, vre, vertex, relationRef) -> { } ); ReadEntity readEntity = entities.map(entity -> entity).get(0); assertThat(readEntity.getRelations(), contains( allOf( hasProperty("entityId", equalTo(stuffId.toString())), hasProperty("collectionName", equalTo("teststuffs")), hasProperty("entityType", equalTo("teststuff")), hasProperty("relationType", equalTo("isCreatorOf")) ) )); }
@Override public DataStream<ReadEntity> getCollection(Collection collection, int start, int rows, boolean withRelations, CustomEntityProperties customEntityProperties, CustomRelationProperties customRelationProperties) { GraphTraversal<Vertex, Vertex> entities = getCurrentEntitiesFor(collection.getEntityTypeName()).range(start, start + rows); TinkerPopToEntityMapper tinkerPopToEntityMapper = new TinkerPopToEntityMapper(collection, traversal, mappings, customEntityProperties, customRelationProperties); return new TinkerPopGetCollection( entities.toStream().map(vertex -> tinkerPopToEntityMapper.mapEntity(vertex, withRelations)) ); }
TinkerPopOperations implements DataStoreOperations { @Override public DataStream<ReadEntity> getCollection(Collection collection, int start, int rows, boolean withRelations, CustomEntityProperties customEntityProperties, CustomRelationProperties customRelationProperties) { GraphTraversal<Vertex, Vertex> entities = getCurrentEntitiesFor(collection.getEntityTypeName()).range(start, start + rows); TinkerPopToEntityMapper tinkerPopToEntityMapper = new TinkerPopToEntityMapper(collection, traversal, mappings, customEntityProperties, customRelationProperties); return new TinkerPopGetCollection( entities.toStream().map(vertex -> tinkerPopToEntityMapper.mapEntity(vertex, withRelations)) ); } }
TinkerPopOperations implements DataStoreOperations { @Override public DataStream<ReadEntity> getCollection(Collection collection, int start, int rows, boolean withRelations, CustomEntityProperties customEntityProperties, CustomRelationProperties customRelationProperties) { GraphTraversal<Vertex, Vertex> entities = getCurrentEntitiesFor(collection.getEntityTypeName()).range(start, start + rows); TinkerPopToEntityMapper tinkerPopToEntityMapper = new TinkerPopToEntityMapper(collection, traversal, mappings, customEntityProperties, customRelationProperties); return new TinkerPopGetCollection( entities.toStream().map(vertex -> tinkerPopToEntityMapper.mapEntity(vertex, withRelations)) ); } TinkerPopOperations(TinkerPopGraphManager graphManager);   TinkerPopOperations(TinkerPopGraphManager graphManager, ChangeListener listener,
                      GremlinEntityFetcher entityFetcher, Vres mappings, IndexHandler indexHandler); private  TinkerPopOperations(TinkerPopGraphManager graphManager, Function<IndexHandler, ChangeListener> listener,
                              Function<IndexHandler, GremlinEntityFetcher> entityFetcher, Vres mappings,
                              IndexHandler indexHandler); }
TinkerPopOperations implements DataStoreOperations { @Override public DataStream<ReadEntity> getCollection(Collection collection, int start, int rows, boolean withRelations, CustomEntityProperties customEntityProperties, CustomRelationProperties customRelationProperties) { GraphTraversal<Vertex, Vertex> entities = getCurrentEntitiesFor(collection.getEntityTypeName()).range(start, start + rows); TinkerPopToEntityMapper tinkerPopToEntityMapper = new TinkerPopToEntityMapper(collection, traversal, mappings, customEntityProperties, customRelationProperties); return new TinkerPopGetCollection( entities.toStream().map(vertex -> tinkerPopToEntityMapper.mapEntity(vertex, withRelations)) ); } TinkerPopOperations(TinkerPopGraphManager graphManager);   TinkerPopOperations(TinkerPopGraphManager graphManager, ChangeListener listener,
                      GremlinEntityFetcher entityFetcher, Vres mappings, IndexHandler indexHandler); private  TinkerPopOperations(TinkerPopGraphManager graphManager, Function<IndexHandler, ChangeListener> listener,
                              Function<IndexHandler, GremlinEntityFetcher> entityFetcher, Vres mappings,
                              IndexHandler indexHandler); @Override byte[] getVreImageBlob(String vreName); @Override void success(); @Override void rollback(); @Override void close(); @Override UUID acceptRelation(Collection collection, CreateRelation createRelation); @Override void createEntity(Collection col, Optional<Collection> baseCollection, CreateEntity input); @Override ReadEntity getEntity(UUID id, Integer rev, Collection collection,
                              CustomEntityProperties customEntityProperties,
                              CustomRelationProperties customRelationProperties); @Override List<RelationType> getRelationTypes(); @Override DataStream<ReadEntity> getCollection(Collection collection, int start, int rows,
                                              boolean withRelations,
                                              CustomEntityProperties customEntityProperties,
                                              CustomRelationProperties customRelationProperties); @Override List<QuickSearchResult> doQuickSearch(Collection collection, QuickSearch quickSearch, int limit); @Override List<QuickSearchResult> doKeywordQuickSearch(Collection collection, String keywordType,
                                                      QuickSearch quickSearch, int limit); @Override int replaceEntity(Collection collection, UpdateEntity updateEntity); @Override void replaceRelation(Collection collection, UpdateRelation updateRelation); @Override int deleteEntity(Collection collection, UUID id, Change modified); @Override Vres loadVres(); @Override boolean databaseIsEmptyExceptForMigrations(); @Override void initDb(Vres mappings, RelationType... relationTypes); @Override void saveRelationTypes(RelationType... relationTypes); @Override void saveVre(Vre vre); @Override void addPid(UUID id, int rev, URI pidUri); @Override void addTypeToEntity(UUID id, Collection typeToAdd); @Override void moveEdges(int fromVertexId, int toVertexId); }
TinkerPopOperations implements DataStoreOperations { @Override public DataStream<ReadEntity> getCollection(Collection collection, int start, int rows, boolean withRelations, CustomEntityProperties customEntityProperties, CustomRelationProperties customRelationProperties) { GraphTraversal<Vertex, Vertex> entities = getCurrentEntitiesFor(collection.getEntityTypeName()).range(start, start + rows); TinkerPopToEntityMapper tinkerPopToEntityMapper = new TinkerPopToEntityMapper(collection, traversal, mappings, customEntityProperties, customRelationProperties); return new TinkerPopGetCollection( entities.toStream().map(vertex -> tinkerPopToEntityMapper.mapEntity(vertex, withRelations)) ); } TinkerPopOperations(TinkerPopGraphManager graphManager);   TinkerPopOperations(TinkerPopGraphManager graphManager, ChangeListener listener,
                      GremlinEntityFetcher entityFetcher, Vres mappings, IndexHandler indexHandler); private  TinkerPopOperations(TinkerPopGraphManager graphManager, Function<IndexHandler, ChangeListener> listener,
                              Function<IndexHandler, GremlinEntityFetcher> entityFetcher, Vres mappings,
                              IndexHandler indexHandler); @Override byte[] getVreImageBlob(String vreName); @Override void success(); @Override void rollback(); @Override void close(); @Override UUID acceptRelation(Collection collection, CreateRelation createRelation); @Override void createEntity(Collection col, Optional<Collection> baseCollection, CreateEntity input); @Override ReadEntity getEntity(UUID id, Integer rev, Collection collection,
                              CustomEntityProperties customEntityProperties,
                              CustomRelationProperties customRelationProperties); @Override List<RelationType> getRelationTypes(); @Override DataStream<ReadEntity> getCollection(Collection collection, int start, int rows,
                                              boolean withRelations,
                                              CustomEntityProperties customEntityProperties,
                                              CustomRelationProperties customRelationProperties); @Override List<QuickSearchResult> doQuickSearch(Collection collection, QuickSearch quickSearch, int limit); @Override List<QuickSearchResult> doKeywordQuickSearch(Collection collection, String keywordType,
                                                      QuickSearch quickSearch, int limit); @Override int replaceEntity(Collection collection, UpdateEntity updateEntity); @Override void replaceRelation(Collection collection, UpdateRelation updateRelation); @Override int deleteEntity(Collection collection, UUID id, Change modified); @Override Vres loadVres(); @Override boolean databaseIsEmptyExceptForMigrations(); @Override void initDb(Vres mappings, RelationType... relationTypes); @Override void saveRelationTypes(RelationType... relationTypes); @Override void saveVre(Vre vre); @Override void addPid(UUID id, int rev, URI pidUri); @Override void addTypeToEntity(UUID id, Collection typeToAdd); @Override void moveEdges(int fromVertexId, int toVertexId);  }