usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [08/22] incubator-usergrid git commit: fix connections
Date Tue, 26 May 2015 18:13:07 GMT
fix connections


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

Branch: refs/heads/USERGRID-608
Commit: 0c16f0e5a0655100dd875beae63574eec3218207
Parents: 5b1dfa1
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Thu May 14 16:30:22 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Thu May 14 16:30:22 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  2 +-
 .../corepersistence/CpRelationManager.java      | 39 ++++++--------------
 .../corepersistence/index/IndexServiceImpl.java |  3 +-
 .../usergrid/persistence/RelationManager.java   |  2 -
 .../serialization/impl/EdgesObservableImpl.java |  2 +
 .../usergrid/management/OrganizationIT.java     |  8 ++--
 .../resources/usergrid-custom-test.properties   |  1 +
 7 files changed, 21 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c16f0e5/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 63018cb..3f615b4 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
@@ -2622,7 +2622,7 @@ public class CpEntityManager implements EntityManager {
 
             String collectionName = Schema.defaultCollectionName( eType );
             CpRelationManager cpr = ( CpRelationManager ) getRelationManager( getApplication()
);
-            cpr.addToCollection( collectionName, entity, cpEntity, false );
+            cpr.addToCollection( collectionName, entity);
 
             // Invoke counters
             incrementEntityCollection( collectionName, timestamp );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c16f0e5/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 4993d88..797788e 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
@@ -20,6 +20,7 @@ package org.apache.usergrid.corepersistence;
 import java.util.*;
 
 import org.apache.usergrid.persistence.graph.*;
+import org.apache.usergrid.utils.InflectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
@@ -343,22 +344,10 @@ public class CpRelationManager implements RelationManager {
             return null;
         }
 
-        return addToCollection( collectionName, itemRef, ( collection != null &&
collection.getLinkedCollection() != null ) );
-    }
-
-
-    public Entity addToCollection( String collectionName, EntityRef itemRef, boolean connectBack
) throws Exception {
 
         Id entityId = new SimpleId( itemRef.getUuid(), itemRef.getType() );
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity = ( ( CpEntityManager
) em ).load( entityId );
-
-        return addToCollection( collectionName, itemRef, memberEntity, connectBack );
-    }
-
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity = ( ( CpEntityManager
) em ).load(entityId);
 
-    public Entity addToCollection( final String collectionName, final EntityRef itemRef,
-                                   final org.apache.usergrid.persistence.model.entity.Entity
memberEntity,
-                                   final boolean connectBack ) throws Exception {
 
         // don't fetch entity if we've already got one
         final Entity itemEntity;
@@ -373,10 +362,6 @@ public class CpRelationManager implements RelationManager {
             return null;
         }
 
-        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collectionName );
-        if ( ( collection != null ) && !collection.getType().equals( itemRef.getType()
) ) {
-            return null;
-        }
 
 
         if ( memberEntity == null ) {
@@ -393,8 +378,10 @@ 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
@@ -404,6 +391,13 @@ public class CpRelationManager implements RelationManager {
         }
 
         indexService.queueNewEdge(applicationScope, memberEntity, edge);
+        //reverse
+        if(!cpHeadEntity.getId().getType().equals("application")) {
+            String pluralType =  InflectionUtils.pluralize(cpHeadEntity.getId().getType());
+            final Edge reverseEdge = createCollectionEdge(memberEntity.getId(), pluralType,
cpHeadEntity.getId());
+            gm.writeEdge(reverseEdge).toBlocking().last();
+            indexService.queueNewEdge(applicationScope, cpHeadEntity, reverseEdge);
+        }
 
 
         if ( logger.isDebugEnabled() ) {
@@ -417,17 +411,6 @@ public class CpRelationManager implements RelationManager {
     }
 
 
-    @Override
-    public Entity addToCollections( List<EntityRef> owners, String collectionName )
throws Exception {
-
-        // TODO: this addToCollections() implementation seems wrong.
-        for ( EntityRef eref : owners ) {
-            addToCollection( collectionName, eref );
-        }
-
-        return null;
-    }
-
 
     @Override
     public Entity createItemInCollection( String collectionName, String itemType, Map<String,
Object> properties )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c16f0e5/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
index 1fc8eea..9bb0728 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
@@ -138,10 +138,11 @@ public class IndexServiceImpl implements IndexService {
 
             //if the node is the target node, generate our scope correctly
             if ( edge.getTargetNode().equals( entity.getId() ) ) {
+
                 return generateScopeFromSource( edge );
             }
 
-            return generateScopeFromTarget( edge );
+            throw new IllegalArgumentException("target not equal to entity + "+entity.getId());
         } ).flatMap( indexEdge -> {
 
             final ApplicationEntityIndex ei = entityIndexFactory.createApplicationEntityIndex(
applicationScope );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c16f0e5/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
index 0b2fca8..0011183 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
@@ -54,8 +54,6 @@ public interface RelationManager {
 
     public Entity addToCollection( String collectionName, EntityRef itemRef ) throws Exception;
 
-    public Entity addToCollections( List<EntityRef> owners, String collectionName )
throws Exception;
-
     public Entity createItemInCollection( String collectionName, String itemType, Map<String,
Object> properties )
             throws Exception;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c16f0e5/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgesObservableImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgesObservableImpl.java
b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgesObservableImpl.java
index df9e094..55d9d7d 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgesObservableImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgesObservableImpl.java
@@ -126,4 +126,6 @@ public class EdgesObservableImpl implements EdgesObservable {
                     Optional.<Edge>absent() ) );
         } );
     }
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c16f0e5/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
index cbd0e6d..3c93fa3 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
@@ -73,14 +73,14 @@ public class OrganizationIT {
         setup.getEntityIndex().refresh();
         Map<UUID, String> userOrganizations = setup.getMgmtSvc().getOrganizationsForAdminUser(
             organization.getOwner().getUuid() );
-        assertEquals( "wrong number of organizations", 1, userOrganizations.size() );
+        assertEquals("wrong number of organizations", 1, userOrganizations.size());
 
         List<UserInfo> users = setup.getMgmtSvc().getAdminUsersForOrganization(
-            organization.getOrganization().getUuid() );
-        assertEquals( "wrong number of users", 1, users.size() );
+            organization.getOrganization().getUuid());
+        assertEquals("wrong number of users", 1, users.size());
 
         ApplicationInfo applicationInfo = setup.getMgmtSvc().createApplication(organization.getOrganization().getUuid(),
"ed-application");
-        assertNotNull( applicationInfo.getId() );
+        assertNotNull(applicationInfo.getId());
 
 
         setup.getEntityIndex().refresh();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c16f0e5/stack/services/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/usergrid-custom-test.properties b/stack/services/src/test/resources/usergrid-custom-test.properties
index b5f86ae..d01231f 100644
--- a/stack/services/src/test/resources/usergrid-custom-test.properties
+++ b/stack/services/src/test/resources/usergrid-custom-test.properties
@@ -32,6 +32,7 @@ usergrid.notifications.listener.run=false
 elasticsearch.index_prefix=services_tests
 
 elasticsearch.buffer_timeout=1
+elasticsearch.queue_impl.resolution=true
 
 
 


Mime
View raw message