usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [33/50] [abbrv] incubator-usergrid git commit: observable changes
Date Thu, 28 May 2015 12:53:38 GMT
observable changes


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f67961d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f67961d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f67961d6

Branch: refs/heads/USERGRID-669
Commit: f67961d6a69a80ab6fb74f3c48bc414588329ba1
Parents: f7b47a8
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Tue May 26 14:25:09 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Tue May 26 14:25:09 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      | 58 ++++++++++----------
 1 file changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f67961d6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index c31288a..bc3c803 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -386,37 +386,37 @@ public class CpRelationManager implements RelationManager {
 
         // create graph edge connection from head entity to member entity
         final Edge edge = createCollectionEdge( cpHeadEntity.getId(), collectionName, memberEntity.getId()
);
-
-        GraphManager gm = managerCache.getGraphManager( applicationScope );
-        gm.writeEdge( edge ).toBlocking().last();
-        //reverse
-
-
-        //perform indexing
-
-        if ( logger.isDebugEnabled() ) {
-            logger.debug( "Wrote edge {}", edge );
-        }
-
-
-        //check if we need to reverse our edges
-
-
         final String linkedCollection = collection.getLinkedCollection();
 
-        /**
-         * Nothing to link
-         */
-        if ( linkedCollection != null ) {
-            String pluralType = InflectionUtils.pluralize( cpHeadEntity.getId().getType()
);
-            final Edge reverseEdge = createCollectionEdge( memberEntity.getId(), pluralType,
cpHeadEntity.getId() );
-            gm.writeEdge( reverseEdge ).toBlocking().last();
-        }
-
-
-        indexService.queueNewEdge( applicationScope, memberEntity, edge );
+        GraphManager gm = managerCache.getGraphManager(applicationScope);
 
+        gm.writeEdge( edge )
+            .doOnNext( writtenEdge -> {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Wrote edge {}", writtenEdge);
+                }
+            })
+            .filter(writtenEdge -> linkedCollection != null )
+            .flatMap(writtenEdge -> {
+                final String pluralType = InflectionUtils.pluralize( cpHeadEntity.getId().getType()
);
+                final Edge reverseEdge = createCollectionEdge( memberEntity.getId(), pluralType,
cpHeadEntity.getId() );
+
+                //reverse
+                return gm.writeEdge(reverseEdge).doOnNext(reverseEdgeWritten -> {
+                    indexService.queueNewEdge(applicationScope, cpHeadEntity, reverseEdge);
+                });
+            })
+            .doOnCompleted(() -> {
+                indexService.queueNewEdge(applicationScope, memberEntity, edge);
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Added entity {}:{} to collection {}", new Object[]{
+                        itemRef.getUuid().toString(), itemRef.getType(), collectionName
+                    });
+                }
+            })
+            .toBlocking().lastOrDefault(null);
 
+        //check if we need to reverse our edges
 
 
         if ( logger.isDebugEnabled() ) {
@@ -622,7 +622,7 @@ public class CpRelationManager implements RelationManager {
 
         final IdBuilder pipelineBuilder =
             pipelineBuilderFactory.create( applicationScope ).withCursor( query.getCursor()
)
-                                  .withLimit( query.getLimit() ).fromId( cpHeadEntity.getId()
);
+                                  .withLimit( query.getLimit() ).fromId(cpHeadEntity.getId());
 
 
         final EntityBuilder results;
@@ -904,7 +904,7 @@ public class CpRelationManager implements RelationManager {
 
         query = adjustQuery( query );
 
-        final Optional<String> entityType = Optional.fromNullable( query.getEntityType()
) ;
+        final Optional<String> entityType = Optional.fromNullable(query.getEntityType())
;
         //set startid -- graph | es query filter -- load entities filter (verifies exists)
--> results page collector
         // -> 1.0 results
 


Mime
View raw message