usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [21/50] usergrid git commit: add entity size to base entity
Date Tue, 08 Sep 2015 21:06:24 GMT
add entity size to base entity


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

Branch: refs/heads/usergrid-103-upgrade-jersey
Commit: dad313d32208b348496a8475dfa9ad7ce13302e9
Parents: 28d966f
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Mon Aug 31 17:30:18 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Mon Aug 31 17:30:18 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpEntityManager.java       |  6 ++----
 .../corepersistence/results/EntityQueryExecutor.java    |  4 +---
 .../org/apache/usergrid/persistence/AbstractEntity.java | 12 ++++++++++--
 .../java/org/apache/usergrid/persistence/Entity.java    |  5 ++++-
 .../apache/usergrid/persistence/EntityManagerIT.java    |  8 ++++----
 .../cassandra/EntityManagerFactoryImplIT.java           |  2 +-
 .../usergrid/persistence/model/entity/Entity.java       | 10 ++--------
 .../persistence/model/field/value/EntityObject.java     | 10 ++++++++++
 8 files changed, 34 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/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 d19d6e3..ac9d08f 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
@@ -469,9 +469,7 @@ public class CpEntityManager implements EntityManager {
         Class clazz = Schema.getDefaultSchema().getEntityClass( entityRef.getType() );
 
         Entity entity = EntityFactory.newEntity( entityRef.getUuid(), entityRef.getType(),
clazz );
-        entity.setProperties( CpEntityMapUtils.toMap( cpEntity ) );
-
-
+        entity.setProperties(  cpEntity  );
         return entity;
     }
 
@@ -526,7 +524,7 @@ public class CpEntityManager implements EntityManager {
         }
 
         A entity = EntityFactory.newEntity( entityId, type, entityClass );
-        entity.setProperties( CpEntityMapUtils.toMap( cpEntity ) );
+        entity.setProperties(  cpEntity  );
 
         return entity;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityQueryExecutor.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityQueryExecutor.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityQueryExecutor.java
index 7a8b273..808fcc6 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityQueryExecutor.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityQueryExecutor.java
@@ -78,9 +78,7 @@ public abstract class EntityQueryExecutor extends ObservableQueryExecutor<Entity
         org.apache.usergrid.persistence.Entity entity =
             EntityFactory.newEntity( entityId.getUuid(), entityId.getType() );
 
-        Map<String, Object> entityMap = CpEntityMapUtils.toMap( cpEntity );
-        entity.addProperties( entityMap );
-        entity.setMetadata("size", cpEntity.getSize());
+        entity.setProperties( cpEntity );
 
         return entity;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/stack/core/src/main/java/org/apache/usergrid/persistence/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/AbstractEntity.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/AbstractEntity.java
index 49d0cf9..2c32a6e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/AbstractEntity.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/AbstractEntity.java
@@ -27,7 +27,9 @@ import java.util.UUID;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
 import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.apache.usergrid.persistence.model.entity.EntityToMapConverter;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 
@@ -165,7 +167,7 @@ public abstract class AbstractEntity implements Entity {
 
     @Override
     public final Object getProperty( String propertyName ) {
-        return Schema.getDefaultSchema().getEntityProperty( this, propertyName );
+        return Schema.getDefaultSchema().getEntityProperty(this, propertyName);
     }
 
 
@@ -178,7 +180,13 @@ public abstract class AbstractEntity implements Entity {
     @Override
     public void setProperties( Map<String, Object> properties ) {
         dynamic_properties = new TreeMap<String, Object>( String.CASE_INSENSITIVE_ORDER
);
-        addProperties( properties );
+        addProperties(properties);
+    }
+
+    @Override
+    public void setProperties(org.apache.usergrid.persistence.model.entity.Entity cpEntity){
+        setProperties( CpEntityMapUtils.toMap(cpEntity) );
+        this.setSize(cpEntity.getSize());
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/stack/core/src/main/java/org/apache/usergrid/persistence/Entity.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/Entity.java b/stack/core/src/main/java/org/apache/usergrid/persistence/Entity.java
index 5f353d9..bbde733 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/Entity.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/Entity.java
@@ -68,7 +68,9 @@ public interface Entity extends EntityRef, Comparable<Entity> {
     @JsonIgnore
     public Map<String, Object> getProperties();
 
-    public void setProperties( Map<String, Object> properties );
+    void setProperties( Map<String, Object> properties );
+
+    void setProperties(org.apache.usergrid.persistence.model.entity.Entity cpEntity);
 
     public void addProperties( Map<String, Object> properties );
 
@@ -106,4 +108,5 @@ public interface Entity extends EntityRef, Comparable<Entity> {
     @JsonIgnore
     long getSize();
     void setSize(long size);
+
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
index 1fc97e9..d81cad2 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
@@ -159,7 +159,7 @@ public class EntityManagerIT extends AbstractCoreIT {
             assertTrue( "thing name should start with \"thing\"", property.toString().startsWith(
"thing" ) );
 
             Map<String, Object> properties = en.getProperties();
-            assertEquals( "number of properties wrong", 5, properties.size() );
+            assertEquals( "number of properties wrong", 6, properties.size() );
         }
 
         i = 0;
@@ -241,7 +241,7 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         Map<String, Object> props = em.getProperties( entity );
         assertNotNull( "properties should not be null", props );
-        assertEquals( "wrong number of properties", 8, props.size() );
+        assertEquals( "wrong number of properties", 9, props.size() );
 
         assertEquals( "wrong value for property alpha", ( long ) 1, props.get( "alpha" )
);
         assertEquals( "wrong value for property beta", ( long ) 2, props.get( "beta" ) );
@@ -255,7 +255,7 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         props = em.getProperties( entity );
         assertNotNull( "properties should not be null", props );
-        assertEquals( "wrong number of properties", 7, props.size() );
+        assertEquals( "wrong number of properties", 8, props.size() );
     }
 
 
@@ -370,7 +370,7 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         Map<String, Object> props = em.getProperties( entity );
         assertNotNull( "properties should not be null", props );
-        assertEquals( "wrong number of properties", 6, props.size() );
+        assertEquals( "wrong number of properties", 7, props.size() );
 
         json = ( Map<String, Object> ) props.get( "json" );
         assertEquals( "wrong size for property alpha", 3, json.size() );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index ec5688d..abd55ea 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -266,7 +266,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
             assertTrue( "thing name should start with \"thing\"", property.toString().startsWith(
"thing" ) );
 
             Map<String, Object> properties = en.getProperties();
-            assertEquals( "number of properties wrong", 5, properties.size() );
+            assertEquals( "number of properties wrong", 6, properties.size() );
         }
 
         i = 0;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
index 013b37a..b915e4f 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
@@ -59,8 +59,7 @@ public class Entity extends EntityObject {
     @JsonProperty
     private UUID version;
 
-    @JsonIgnore
-    private long size;
+
 
 
     /**
@@ -158,10 +157,5 @@ public class Entity extends EntityObject {
         return getVersion() != null;
     }
 
-    public long getSize() {
-        return this.size;
-    }
-    public void setSize(long size) {
-        this.size = size;
-    }
+
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dad313d3/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
index 12915e2..db44e87 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
@@ -38,6 +38,9 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
 @JsonIgnoreProperties(ignoreUnknown = true)
 public class EntityObject implements Serializable {
 
+    @JsonIgnore
+    private long size;
+
     /**
      * Fields the users can set
      */
@@ -99,4 +102,11 @@ public class EntityObject implements Serializable {
         fields.clear();
         fields.putAll( fieldMap );
     }
+
+    public long getSize() {
+        return this.size;
+    }
+    public void setSize(long size) {
+        this.size = size;
+    }
 }


Mime
View raw message