Github user tnine commented on a diff in the pull request:
https://github.com/apache/usergrid/pull/386#discussion_r39808860
--- Diff:
stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
---
@@ -117,4 +140,68 @@ public ConnectionServiceImpl( final
PipelineBuilderFactory pipelineBuilderFactor
return results;
}
+
+
+ @Override
+ public Observable<ConnectionScope> deDupeConnections(
+ final Observable<ApplicationScope> applicationScopeObservable ) {
+
+
+ final Observable<EntityIdScope> entityIds =
allEntityIdsObservable.getEntities( applicationScopeObservable );
+ //now we have an observable of entityIds. Walk each connection
type
+
+ //get all edge types for connections
+ return entityIds.flatMap( entityIdScope -> {
+
+ final ApplicationScope applicationScope =
entityIdScope.getApplicationScope();
+ final Id entityId = entityIdScope.getId();
+
+ final GraphManager gm = graphManagerFactory.createEdgeManager(
applicationScope );
+
+ logger.debug( "Checking connections of id {} in application
{}", entityId, applicationScope );
+
+ return gm.getEdgeTypesFromSource(
+ new SimpleSearchEdgeType( entityId,
CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
+
+ //now load all edges from this node of this type
+ .flatMap( edgeType -> {
+
+ logger.debug( "Found edge of types of {}, searching
for edges", edgeType );
+
+ final SearchByEdgeType searchByEdge =
+ new SimpleSearchByEdgeType( entityId, edgeType,
Long.MAX_VALUE,
+ SearchByEdgeType.Order.DESCENDING,
Optional.absent() );
+
+ //load edges from the source the with type specified
+ return gm.loadEdgesFromSource( searchByEdge );
+ } )
+
+ //now that we have a stream of edges, stream all
versions
+ .flatMap( edge -> {
+
+ logger.debug( "Found edge {}, searching for multiple
versions of edge", edge );
+
+ final SearchByEdge searchByEdge =
--- End diff --
TODO: We should discuss semantics of re POSTing a connection. If we want
to retain most recent post, we'll need to change this migration as well as the
write logic in Relation manager
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---