You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/10/10 17:50:42 UTC

[35/43] git commit: Added type uuid mapping to the create call

Added type uuid mapping to the create call


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

Branch: refs/heads/two-dot-o-events
Commit: de887125e85f68e2c08aba07becb2799228eb1d4
Parents: d824ee2
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 9 17:34:38 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 9 17:37:34 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 30 ++++++++++++++++----
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/de887125/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 3aea391..49b7d25 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -523,7 +523,10 @@ public class CpEntityManager implements EntityManager {
 
     @Override
     public void delete( EntityRef entityRef ) throws Exception {
-        deleteAsync( entityRef ).toBlockingObservable().lastOrDefault(null);
+        deleteAsync( entityRef ).toBlocking().lastOrDefault(null);
+        //delete from our UUID index
+        MapManager mm = getMapManagerForTypes();
+        mm.delete(entityRef.getUuid().toString() );
     }
 
 
@@ -2207,13 +2210,12 @@ public class CpEntityManager implements EntityManager {
     @Override
     public Entity get( UUID uuid ) throws Exception {
 
-        Id mapOwner = new SimpleId( applicationId, TYPE_APPLICATION );
-        MapScope ms = new MapScopeImpl( mapOwner, TYPES_BY_UUID_MAP );
-        MapManager mm = managerCache.getMapManager( ms );
+        MapManager mm = getMapManagerForTypes();
         String entityType = mm.getString(uuid.toString() );
 
         final Entity entity;
 
+      //this is the fall back, why isn't this writt
         if ( entityType == null ) {
 
             Query q = Query.fromQL(
@@ -2229,7 +2231,19 @@ public class CpEntityManager implements EntityManager {
         }
 
         return entity;
-    } 
+    }
+
+
+    /**
+     * Get the map manager for uuid mapping
+     */
+    private MapManager getMapManagerForTypes() {
+        Id mapOwner = new SimpleId( applicationId, TYPE_APPLICATION );
+        MapScope ms = new MapScopeImpl( mapOwner, TYPES_BY_UUID_MAP );
+        MapManager mm = managerCache.getMapManager( ms );
+
+        return mm;
+    }
 
 
     @Override
@@ -2521,7 +2535,7 @@ public class CpEntityManager implements EntityManager {
                 entityToCpEntity( entity, importId );
 
         // prepare to write and index Core Persistence Entity into default scope
-        CollectionScope collectionScope = new CollectionScopeImpl( 
+        CollectionScope collectionScope = new CollectionScopeImpl(
                 applicationScope.getApplication(), 
                 applicationScope.getApplication(),
                 CpNamingUtils.getCollectionScopeNameFromEntityType( eType ) );
@@ -2589,6 +2603,10 @@ public class CpEntityManager implements EntityManager {
             incrementEntityCollection( collectionName, timestamp );
         }
 
+        //write to our types map
+        MapManager mm = getMapManagerForTypes();
+        mm.putString( itemId.toString(), entity.getType() );
+
 
         return entity;
     }