You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/03/19 02:20:50 UTC

[3/9] git commit: Minor refactoring to allow legacy EntityManager to be used outside of tests.

Minor refactoring to allow legacy EntityManager to be used outside of tests.


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

Branch: refs/heads/asyncqueue
Commit: 3e6e7e82fbf9db14fb730e6aef65e331f9b7d11c
Parents: 904713f
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Mar 14 08:38:23 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Mar 14 08:38:23 2014 -0400

----------------------------------------------------------------------
 .../index/legacy/EntityManagerFacade.java       | 201 +++++++++++++++++++
 .../apache/usergrid/utils/EntityBuilder.java    | 177 ++++++++++++++++
 .../index/impl/EntityCollectionIndexTest.java   |   2 +-
 .../persistence/index/legacy/EntityBuilder.java | 177 ----------------
 .../index/legacy/EntityManagerFacade.java       | 200 ------------------
 5 files changed, 379 insertions(+), 378 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
new file mode 100644
index 0000000..de1b9b6
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.legacy;
+
+import org.apache.usergrid.utils.EntityBuilder;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntityCollectionManager;
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.index.EntityCollectionIndex;
+import org.apache.usergrid.persistence.index.EntityCollectionIndexFactory;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.value.Location;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.persistence.query.EntityRef;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/** 
+ * Implements just enough of the old EntityManager interface to get old tests imported from the
+ * Usergrid 1.0 Core module working against the new Core Persistence index & query system.
+ */
+public class EntityManagerFacade {
+    private static final Logger logger = LoggerFactory.getLogger( EntityManagerFacade.class );
+
+    private final Id orgId;
+    private final Id appId;
+    private final EntityCollectionManagerFactory ecmf;
+    private final EntityCollectionIndexFactory ecif;
+    private final Map<String, String> typesByCollectionNames = new HashMap<String, String>();
+
+    private final Map<CollectionScope, EntityCollectionManager> managers = new HashMap<>();
+    private final Map<CollectionScope, EntityCollectionIndex> indexes = new HashMap<>();
+    
+    public EntityManagerFacade( 
+        Id orgId, 
+        Id appId, 
+        EntityCollectionManagerFactory ecmf, 
+        EntityCollectionIndexFactory ecif ) {
+
+        this.appId = appId;
+        this.orgId = orgId;
+        this.ecmf = ecmf;
+        this.ecif = ecif;
+    }
+
+    private EntityCollectionIndex getIndex( CollectionScope scope ) { 
+        EntityCollectionIndex eci = indexes.get( scope );
+        if ( eci == null ) {
+            eci = ecif.createCollectionIndex( scope );
+            indexes.put( scope, eci );
+        }
+        return eci;
+    }
+
+    private EntityCollectionManager getManager( CollectionScope scope ) { 
+        EntityCollectionManager ecm = managers.get( scope );
+        if ( ecm == null ) {
+            ecm = ecmf.createCollectionManager( scope );
+            managers.put( scope, ecm);
+        }
+        return ecm;
+    }
+
+    public Entity create( String type, Map<String, Object> properties ) {
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+        final String collectionName;
+        if ( type.endsWith("y") ) {
+            collectionName = type.substring( 0, type.length() - 1) + "ies";
+        } else {
+            collectionName = type + "s";
+        }
+        typesByCollectionNames.put( collectionName, type );
+
+        Entity entity = new Entity(new SimpleId(UUIDGenerator.newTimeUUID(), type ));
+        entity = EntityBuilder.fromMap( scope.getName(), entity, properties );
+        entity.setField(new LongField("created", entity.getId().getUuid().timestamp()) );
+        entity.setField(new LongField("modified", entity.getId().getUuid().timestamp()) );
+        entity = ecm.write( entity ).toBlockingObservable().last();
+
+        eci.index( entity );
+        return entity;
+    }
+
+    public Results searchCollection( Entity user, String collectionName, Query query ) {
+
+        String type = typesByCollectionNames.get( collectionName );
+		if ( type == null ) {
+			throw new RuntimeException( 
+					"No type found for collection name: " + collectionName);
+		}
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+
+        EntityCollectionIndex eci = getIndex( scope );
+        Results results = eci.execute( query );
+        return results;
+    }
+
+    public Entity get( Id id ) {
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, id.getType() );
+        EntityCollectionManager ecm = getManager( scope );
+        return ecm.load( id ).toBlockingObservable().last();
+    }
+
+    public void addToCollection( Entity user, String collectionName, Entity entity ) {
+        // basically a no-op except that can now map Entity type to collection name
+        typesByCollectionNames.put( collectionName, entity.getId().getType() );
+    }
+
+    public Entity getApplicationRef() {
+        return new Entity();
+    }
+
+    public void update( Entity entity ) {
+
+        String type = entity.getId().getType();
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+        final String collectionName;
+        if ( type.endsWith("y") ) {
+            collectionName = type.substring( 0, type.length() - 1) + "ies";
+        } else {
+            collectionName = type + "s";
+        }
+        typesByCollectionNames.put( collectionName, type );
+        
+        entity = ecm.write( entity ).toBlockingObservable().last();
+
+        eci.index( entity );
+    }
+
+	
+	public void delete( Entity entity ) {
+
+        String type = entity.getId().getType();
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+		eci.deindex( entity );
+		ecm.delete( entity.getId() );
+	}
+
+
+	public void setProperty( EntityRef entityRef, String fieldName, double lat, double lon ) {
+
+        String type = entityRef.getId().getType();
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+		Entity entity = ecm.load( entityRef.getId() ).toBlockingObservable().last();
+		entity.setField( new LocationField( fieldName, new Location( lat, lon )));
+
+        entity = ecm.write(entity).toBlockingObservable().last();
+        eci.index(entity);
+	}
+
+
+    public void refreshIndex() {
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "dummy" );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+		eci.refresh();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
new file mode 100644
index 0000000..c9e1c84
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
+package org.apache.usergrid.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.field.BooleanField;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
+import org.apache.usergrid.persistence.model.field.Field;
+import org.apache.usergrid.persistence.model.field.FloatField;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.field.value.Location;
+
+
+public class EntityBuilder {
+
+    public static Entity fromMap( String scope, Map<String, Object> item ) {
+        return fromMap( scope, null, item );
+    }
+
+    public static Entity fromMap( String scope, Entity entity, Map<String, Object> map ) {
+
+        if ( entity == null ) {
+            entity = new Entity();
+        }
+
+        for ( String fieldName : map.keySet() ) {
+
+            Object value = map.get( fieldName );
+
+            if ( value instanceof String ) {
+                entity.setField( new StringField( fieldName, (String)value ));
+
+            } else if ( value instanceof Boolean ) {
+                entity.setField( new BooleanField( fieldName, (Boolean)value ));
+                        
+            } else if ( value instanceof Integer ) {
+                entity.setField( new IntegerField( fieldName, (Integer)value ));
+
+            } else if ( value instanceof Double ) {
+                entity.setField( new DoubleField( fieldName, (Double)value ));
+
+		    } else if ( value instanceof Float ) {
+                entity.setField( new FloatField( fieldName, (Float)value ));
+				
+            } else if ( value instanceof Long ) {
+                entity.setField( new LongField( fieldName, (Long)value ));
+
+            } else if ( value instanceof List) {
+                entity.setField( listToListField( scope, fieldName, (List)value ));
+
+            } else if ( value instanceof Map ) {
+
+				Field field = null;
+
+				// is the map really a location element?
+				Map<String, Object> m = (Map<String, Object>)value;
+				if ( m.size() == 2) {
+					Double lat = null;
+					Double lon = null;
+					try {
+						if ( m.get("latitude") != null && m.get("longitude") != null ) {
+							lat = Double.parseDouble( m.get("latitude").toString() );
+							lon = Double.parseDouble( m.get("longitude").toString() );
+
+						} else if ( m.get("lat") != null && m.get("lon") != null ) { 
+							lat = Double.parseDouble( m.get("lat").toString() );
+							lon = Double.parseDouble( m.get("lon").toString() );
+						}
+					} catch ( NumberFormatException ignored ) {}
+
+					if ( lat != null && lon != null ) {
+						field = new LocationField( fieldName, new Location( lat, lon ));
+					}
+				}
+
+				if ( field == null ) { 
+
+					// not a location element, process it as map
+					entity.setField( new EntityObjectField( fieldName, 
+						fromMap( scope, (Map<String, Object>)value ))); // recursion
+
+				} else {
+					entity.setField( field );
+				}
+	
+			} else {
+                throw new RuntimeException("Unknown type " + value.getClass().getName());
+            }
+        }
+
+        return entity;
+    }
+
+    
+    private static ListField listToListField( String scope, String fieldName, List list ) {
+
+        if (list.isEmpty()) {
+            return new ListField( fieldName );
+        }
+
+        Object sample = list.get(0);
+
+        if ( sample instanceof Map ) {
+            return new ListField<Entity>( fieldName, processListForField( scope, list ));
+
+        } else if ( sample instanceof List ) {
+            return new ListField<List>( fieldName, processListForField( scope, list ));
+            
+        } else if ( sample instanceof String ) {
+            return new ListField<String>( fieldName, (List<String>)list );
+                    
+        } else if ( sample instanceof Boolean ) {
+            return new ListField<Boolean>( fieldName, (List<Boolean>)list );
+                    
+        } else if ( sample instanceof Integer ) {
+            return new ListField<Integer>( fieldName, (List<Integer>)list );
+
+        } else if ( sample instanceof Double ) {
+            return new ListField<Double>( fieldName, (List<Double>)list );
+
+        } else if ( sample instanceof Long ) {
+            return new ListField<Long>( fieldName, (List<Long>)list );
+
+        } else {
+            throw new RuntimeException("Unknown type " + sample.getClass().getName());
+        }
+    }
+
+    
+    private static List processListForField( String scope, List list ) {
+        if ( list.isEmpty() ) {
+            return list;
+        }
+        Object sample = list.get(0);
+
+        if ( sample instanceof Map ) {
+            List<Entity> newList = new ArrayList<Entity>();
+            for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
+                newList.add( fromMap( scope, map ) );
+            }
+            return newList;
+
+        } else if ( sample instanceof List ) {
+            return processListForField( scope, list ); // recursion
+            
+        } else { 
+            return list;
+        } 
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
index e951098..423780c 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
@@ -43,7 +43,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.persistence.query.Query;
 import org.apache.usergrid.persistence.query.Results;
-import org.apache.usergrid.persistence.index.legacy.EntityBuilder;
+import org.apache.usergrid.utils.EntityBuilder;
 import org.jukito.JukitoRunner;
 import org.jukito.UseModules;
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java
deleted file mode 100644
index fefb8fb..0000000
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  The ASF licenses this file to You
- * under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-
-package org.apache.usergrid.persistence.index.legacy;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.field.BooleanField;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.EntityObjectField;
-import org.apache.usergrid.persistence.model.field.Field;
-import org.apache.usergrid.persistence.model.field.FloatField;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.ListField;
-import org.apache.usergrid.persistence.model.field.LocationField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.field.value.Location;
-
-
-public class EntityBuilder {
-
-    public static Entity fromMap( String scope, Map<String, Object> item ) {
-        return fromMap( scope, null, item );
-    }
-
-    public static Entity fromMap( String scope, Entity entity, Map<String, Object> map ) {
-
-        if ( entity == null ) {
-            entity = new Entity();
-        }
-
-        for ( String fieldName : map.keySet() ) {
-
-            Object value = map.get( fieldName );
-
-            if ( value instanceof String ) {
-                entity.setField( new StringField( fieldName, (String)value ));
-
-            } else if ( value instanceof Boolean ) {
-                entity.setField( new BooleanField( fieldName, (Boolean)value ));
-                        
-            } else if ( value instanceof Integer ) {
-                entity.setField( new IntegerField( fieldName, (Integer)value ));
-
-            } else if ( value instanceof Double ) {
-                entity.setField( new DoubleField( fieldName, (Double)value ));
-
-		    } else if ( value instanceof Float ) {
-                entity.setField( new FloatField( fieldName, (Float)value ));
-				
-            } else if ( value instanceof Long ) {
-                entity.setField( new LongField( fieldName, (Long)value ));
-
-            } else if ( value instanceof List) {
-                entity.setField( listToListField( scope, fieldName, (List)value ));
-
-            } else if ( value instanceof Map ) {
-
-				Field field = null;
-
-				// is the map really a location element?
-				Map<String, Object> m = (Map<String, Object>)value;
-				if ( m.size() == 2) {
-					Double lat = null;
-					Double lon = null;
-					try {
-						if ( m.get("latitude") != null && m.get("longitude") != null ) {
-							lat = Double.parseDouble( m.get("latitude").toString() );
-							lon = Double.parseDouble( m.get("longitude").toString() );
-
-						} else if ( m.get("lat") != null && m.get("lon") != null ) { 
-							lat = Double.parseDouble( m.get("lat").toString() );
-							lon = Double.parseDouble( m.get("lon").toString() );
-						}
-					} catch ( NumberFormatException ignored ) {}
-
-					if ( lat != null && lon != null ) {
-						field = new LocationField( fieldName, new Location( lat, lon ));
-					}
-				}
-
-				if ( field == null ) { 
-
-					// not a location element, process it as map
-					entity.setField( new EntityObjectField( fieldName, 
-						fromMap( scope, (Map<String, Object>)value ))); // recursion
-
-				} else {
-					entity.setField( field );
-				}
-	
-			} else {
-                throw new RuntimeException("Unknown type " + value.getClass().getName());
-            }
-        }
-
-        return entity;
-    }
-
-    
-    private static ListField listToListField( String scope, String fieldName, List list ) {
-
-        if (list.isEmpty()) {
-            return new ListField( fieldName );
-        }
-
-        Object sample = list.get(0);
-
-        if ( sample instanceof Map ) {
-            return new ListField<Entity>( fieldName, processListForField( scope, list ));
-
-        } else if ( sample instanceof List ) {
-            return new ListField<List>( fieldName, processListForField( scope, list ));
-            
-        } else if ( sample instanceof String ) {
-            return new ListField<String>( fieldName, (List<String>)list );
-                    
-        } else if ( sample instanceof Boolean ) {
-            return new ListField<Boolean>( fieldName, (List<Boolean>)list );
-                    
-        } else if ( sample instanceof Integer ) {
-            return new ListField<Integer>( fieldName, (List<Integer>)list );
-
-        } else if ( sample instanceof Double ) {
-            return new ListField<Double>( fieldName, (List<Double>)list );
-
-        } else if ( sample instanceof Long ) {
-            return new ListField<Long>( fieldName, (List<Long>)list );
-
-        } else {
-            throw new RuntimeException("Unknown type " + sample.getClass().getName());
-        }
-    }
-
-    
-    private static List processListForField( String scope, List list ) {
-        if ( list.isEmpty() ) {
-            return list;
-        }
-        Object sample = list.get(0);
-
-        if ( sample instanceof Map ) {
-            List<Entity> newList = new ArrayList<Entity>();
-            for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
-                newList.add( fromMap( scope, map ) );
-            }
-            return newList;
-
-        } else if ( sample instanceof List ) {
-            return processListForField( scope, list ); // recursion
-            
-        } else { 
-            return list;
-        } 
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
deleted file mode 100644
index e8eb5e1..0000000
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  The ASF licenses this file to You
- * under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.index.legacy;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.EntityCollectionManager;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
-import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
-import org.apache.usergrid.persistence.index.EntityCollectionIndex;
-import org.apache.usergrid.persistence.index.EntityCollectionIndexFactory;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.field.LocationField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.value.Location;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.query.EntityRef;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/** 
- * Implements just enough of the old EntityManager interface to get old tests imported from the
- * Usergrid 1.0 Core module working against the new Core Persistence index & query system.
- */
-public class EntityManagerFacade {
-    private static final Logger logger = LoggerFactory.getLogger( EntityManagerFacade.class );
-
-    private final Id orgId;
-    private final Id appId;
-    private final EntityCollectionManagerFactory ecmf;
-    private final EntityCollectionIndexFactory ecif;
-    private final Map<String, String> typesByCollectionNames = new HashMap<String, String>();
-
-    private final Map<CollectionScope, EntityCollectionManager> managers = new HashMap<>();
-    private final Map<CollectionScope, EntityCollectionIndex> indexes = new HashMap<>();
-    
-    public EntityManagerFacade( 
-        Id orgId, 
-        Id appId, 
-        EntityCollectionManagerFactory ecmf, 
-        EntityCollectionIndexFactory ecif ) {
-
-        this.appId = appId;
-        this.orgId = orgId;
-        this.ecmf = ecmf;
-        this.ecif = ecif;
-    }
-
-    private EntityCollectionIndex getIndex( CollectionScope scope ) { 
-        EntityCollectionIndex eci = indexes.get( scope );
-        if ( eci == null ) {
-            eci = ecif.createCollectionIndex( scope );
-            indexes.put( scope, eci );
-        }
-        return eci;
-    }
-
-    private EntityCollectionManager getManager( CollectionScope scope ) { 
-        EntityCollectionManager ecm = managers.get( scope );
-        if ( ecm == null ) {
-            ecm = ecmf.createCollectionManager( scope );
-            managers.put( scope, ecm);
-        }
-        return ecm;
-    }
-
-    public Entity create( String type, Map<String, Object> properties ) {
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-        final String collectionName;
-        if ( type.endsWith("y") ) {
-            collectionName = type.substring( 0, type.length() - 1) + "ies";
-        } else {
-            collectionName = type + "s";
-        }
-        typesByCollectionNames.put( collectionName, type );
-
-        Entity entity = new Entity(new SimpleId(UUIDGenerator.newTimeUUID(), type ));
-        entity = EntityBuilder.fromMap( scope.getName(), entity, properties );
-        entity.setField(new LongField("created", entity.getId().getUuid().timestamp()) );
-        entity.setField(new LongField("modified", entity.getId().getUuid().timestamp()) );
-        entity = ecm.write( entity ).toBlockingObservable().last();
-
-        eci.index( entity );
-        return entity;
-    }
-
-    public Results searchCollection( Entity user, String collectionName, Query query ) {
-
-        String type = typesByCollectionNames.get( collectionName );
-		if ( type == null ) {
-			throw new RuntimeException( 
-					"No type found for collection name: " + collectionName);
-		}
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-
-        EntityCollectionIndex eci = getIndex( scope );
-        Results results = eci.execute( query );
-        return results;
-    }
-
-    public Entity get( Id id ) {
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, id.getType() );
-        EntityCollectionManager ecm = getManager( scope );
-        return ecm.load( id ).toBlockingObservable().last();
-    }
-
-    public void addToCollection( Entity user, String collectionName, Entity entity ) {
-        // basically a no-op except that can now map Entity type to collection name
-        typesByCollectionNames.put( collectionName, entity.getId().getType() );
-    }
-
-    public Entity getApplicationRef() {
-        return new Entity();
-    }
-
-    public void update( Entity entity ) {
-
-        String type = entity.getId().getType();
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-        final String collectionName;
-        if ( type.endsWith("y") ) {
-            collectionName = type.substring( 0, type.length() - 1) + "ies";
-        } else {
-            collectionName = type + "s";
-        }
-        typesByCollectionNames.put( collectionName, type );
-        
-        entity = ecm.write( entity ).toBlockingObservable().last();
-
-        eci.index( entity );
-    }
-
-	
-	public void delete( Entity entity ) {
-
-        String type = entity.getId().getType();
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-		eci.deindex( entity );
-		ecm.delete( entity.getId() );
-	}
-
-
-	public void setProperty( EntityRef entityRef, String fieldName, double lat, double lon ) {
-
-        String type = entityRef.getId().getType();
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-		Entity entity = ecm.load( entityRef.getId() ).toBlockingObservable().last();
-		entity.setField( new LocationField( fieldName, new Location( lat, lon )));
-
-        entity = ecm.write(entity).toBlockingObservable().last();
-        eci.index(entity);
-	}
-
-
-    public void refreshIndex() {
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "dummy" );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-		eci.refresh();
-    }
-
-}