change name of 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/0465628d Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0465628d Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0465628d Branch: refs/heads/USERGRID-614 Commit: 0465628dfc062da24cc8c5fe3837d31c7a4a36a4 Parents: ee13ceb Author: Shawn Feldman <[email protected]> Authored: Fri May 8 12:42:45 2015 -0600 Committer: Shawn Feldman <[email protected]> Committed: Fri May 8 12:42:45 2015 -0600 ---------------------------------------------------------------------- .../corepersistence/CpEntityManager.java | 6 ++-- .../corepersistence/CpRelationManager.java | 29 +++++++++++++------- .../usergrid/persistence/ConnectionRef.java | 4 +-- .../apache/usergrid/persistence/Results.java | 15 ++++------ .../cassandra/ConnectionRefImpl.java | 24 ++++++++-------- .../persistence/EntityConnectionsIT.java | 20 +++++++------- .../management/export/ExportServiceImpl.java | 2 +- 7 files changed, 53 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0465628d/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 e481906..114badb 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 @@ -1442,8 +1442,8 @@ public class CpEntityManager implements EntityManager { @Override public ConnectionRef createConnection( ConnectionRef connection ) throws Exception { - return createConnection( connection.getConnectingEntity(), connection.getConnectionType(), - connection.getConnectedEntity() ); + return createConnection( connection.getSourceRefs(), connection.getConnectionType(), + connection.getTargetRefs() ); } @@ -1501,7 +1501,7 @@ public class CpEntityManager implements EntityManager { @Override public void deleteConnection( ConnectionRef connectionRef ) throws Exception { - EntityRef sourceEntity = connectionRef.getConnectedEntity(); + EntityRef sourceEntity = connectionRef.getTargetRefs(); getRelationManager( sourceEntity ).deleteConnection( connectionRef ); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0465628d/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 e76383f..182f3b2 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 @@ -674,7 +674,7 @@ public class CpRelationManager implements RelationManager { @Override public ConnectionRef createConnection( ConnectionRef connection ) throws Exception { - return createConnection( connection.getConnectionType(), connection.getConnectedEntity() ); + return createConnection( connection.getConnectionType(), connection.getTargetRefs() ); } @@ -770,10 +770,10 @@ public class CpRelationManager implements RelationManager { public void deleteConnection( ConnectionRef connectionRef ) throws Exception { // First, clean up the dictionary records of the connection - EntityRef connectingEntityRef = connectionRef.getConnectingEntity(); // source - EntityRef connectedEntityRef = connectionRef.getConnectedEntity(); // target + EntityRef connectingEntityRef = connectionRef.getSourceRefs(); // source + EntityRef connectedEntityRef = connectionRef.getTargetRefs(); // target - String connectionType = connectionRef.getConnectedEntity().getConnectionType(); + String connectionType = connectionRef.getTargetRefs().getConnectionType(); if ( logger.isDebugEnabled() ) { @@ -913,20 +913,29 @@ public class CpRelationManager implements RelationManager { query = adjustQuery( query ); final String entityType = query.getEntityType(); + //set startid -- graph | es query filter -- load entities filter (verifies exists) --> results page collector -> 1.0 results + // startid -- graph edge load -- entity load (verify) from ids -> results page collector + // startid -- eq query candiddate -- entity load (verify) from canddiates -> results page collector + + //startid -- graph edge load -- entity id verify --> filter to connection ref --> connection ref collector + //startid -- eq query candiddate -- candidate id verify --> filter to connection ref --> connection ref collector final ReadPipelineBuilder readPipelineBuilder = pipelineBuilderFactory.createReadPipelineBuilder(applicationScope); + //readPipelineBuilder.startId().load().collect() //set our fields applicable to both operations - readPipelineBuilder.withCursor( query.getCursor() ); - readPipelineBuilder.withLimit(query.getLimit()); - - //TODO, this should be removed when the CP relation manager is removed - readPipelineBuilder.setStartId( cpHeadEntity.getId() ); + readPipelineBuilder + .withCursor(query.getCursor()) + .withLimit(query.getLimit()) + //TODO, this should be removed when the CP relation manager is removed + .setStartId( cpHeadEntity.getId() ); if ( query.isGraphSearch() ) { - readPipelineBuilder.getConnection( connection ); + // if(query.getResultsLevel() == Level.ALL_PROPERTIES) + readPipelineBuilder.getConnection( connection ); + //else } else { readPipelineBuilder.getConnectionWithQuery( connection, Optional.fromNullable( entityType ), http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0465628d/stack/core/src/main/java/org/apache/usergrid/persistence/ConnectionRef.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/ConnectionRef.java b/stack/core/src/main/java/org/apache/usergrid/persistence/ConnectionRef.java index de92148..14fa689 100644 --- a/stack/core/src/main/java/org/apache/usergrid/persistence/ConnectionRef.java +++ b/stack/core/src/main/java/org/apache/usergrid/persistence/ConnectionRef.java @@ -27,9 +27,9 @@ import java.util.List; */ public interface ConnectionRef extends ConnectedEntityRef, AssociatedEntityRef { - public EntityRef getConnectingEntity(); + public EntityRef getSourceRefs(); public List<ConnectedEntityRef> getPairedConnections(); - public ConnectedEntityRef getConnectedEntity(); + public ConnectedEntityRef getTargetRefs(); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0465628d/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java b/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java index fa221f5..a16a0f8 100644 --- a/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java +++ b/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java @@ -19,15 +19,12 @@ package org.apache.usergrid.persistence; import java.nio.ByteBuffer; import java.util.*; -import java.util.Base64; import java.util.Map.Entry; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.*; import com.google.common.base.Optional; import com.netflix.astyanax.serializers.IntegerSerializer; -import org.apache.commons.codec.binary.*; import org.apache.usergrid.corepersistence.results.QueryExecutor; import org.apache.usergrid.persistence.Query.Level; import org.apache.usergrid.utils.MapUtils; @@ -324,13 +321,13 @@ public class Results implements Iterable<Entity> { ids = new ArrayList<UUID>(); for ( ConnectionRef connection : connections ) { if ( forwardConnections ) { - ConnectedEntityRef c = connection.getConnectedEntity(); + ConnectedEntityRef c = connection.getTargetRefs(); if ( c != null ) { ids.add( c.getUuid() ); } } else { - EntityRef c = connection.getConnectingEntity(); + EntityRef c = connection.getSourceRefs(); if ( c != null ) { ids.add( c.getUuid() ); } @@ -410,13 +407,13 @@ public class Results implements Iterable<Entity> { refs = new ArrayList<EntityRef>(); for ( ConnectionRef connection : connections ) { if ( forwardConnections ) { - ConnectedEntityRef c = connection.getConnectedEntity(); + ConnectedEntityRef c = connection.getTargetRefs(); if ( c != null ) { refs.add( c ); } } else { - EntityRef c = connection.getConnectingEntity(); + EntityRef c = connection.getSourceRefs(); if ( c != null ) { refs.add( c ); } @@ -951,11 +948,11 @@ public class Results implements Iterable<Entity> { level = Level.REFS; for ( ConnectionRef connection : connections ) { if ( forwardConnections ) { - this.setMetadata( connection.getConnectedEntity().getUuid(), "connection", + this.setMetadata( connection.getTargetRefs().getUuid(), "connection", connection.getConnectionType() ); } else { - this.setMetadata( connection.getConnectingEntity().getUuid(), "connection", + this.setMetadata( connection.getSourceRefs().getUuid(), "connection", connection.getConnectionType() ); } } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0465628d/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/ConnectionRefImpl.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/ConnectionRefImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/ConnectionRefImpl.java index 1aa5f6d..5509c37 100644 --- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/ConnectionRefImpl.java +++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/ConnectionRefImpl.java @@ -126,7 +126,7 @@ public class ConnectionRefImpl implements ConnectionRef { public ConnectionRefImpl( ConnectionRef connection ) { - connectingEntity = connection.getConnectingEntity(); + connectingEntity = connection.getSourceRefs(); List<ConnectedEntityRef> pc = connection.getPairedConnections(); if ( pc == null ) { @@ -134,7 +134,7 @@ public class ConnectionRefImpl implements ConnectionRef { } pairedConnections = pc; - connectedEntity = connection.getConnectedEntity(); + connectedEntity = connection.getTargetRefs(); } @@ -163,13 +163,13 @@ public class ConnectionRefImpl implements ConnectionRef { throw new NullPointerException( "ConnectionImpl constructor \'connection\' cannot be null" ); } - connectingEntity = connection.getConnectingEntity(); + connectingEntity = connection.getSourceRefs(); if ( connections.length > 0 ) { pairedConnections = new ArrayList<ConnectedEntityRef>(); pairedConnections.addAll( connection.getPairedConnections() ); - pairedConnections.add( connection.getConnectedEntity() ); + pairedConnections.add( connection.getTargetRefs() ); connectedEntity = connections[connections.length - 1]; @@ -214,7 +214,7 @@ public class ConnectionRefImpl implements ConnectionRef { @Override - public EntityRef getConnectingEntity() { + public EntityRef getSourceRefs() { return connectingEntity; } @@ -286,7 +286,7 @@ public class ConnectionRefImpl implements ConnectionRef { @Override - public ConnectedEntityRef getConnectedEntity() { + public ConnectedEntityRef getTargetRefs() { return connectedEntity; } @@ -330,7 +330,7 @@ public class ConnectionRefImpl implements ConnectionRef { public UUID getUuid() { if ( id == null ) { List<ConnectedEntityRef> var = getPairedConnections(); - id = getId( getConnectingEntity(), getConnectedEntity(), + id = getId( getSourceRefs(), getTargetRefs(), var.toArray(new ConnectedEntityRef[var.size()])); } return id; @@ -344,19 +344,19 @@ public class ConnectionRefImpl implements ConnectionRef { public UUID getIndexId() { - return getIndexId( getConnectingEntity(), getConnectionType(), getConnectedEntityType(), + return getIndexId( getSourceRefs(), getConnectionType(), getConnectedEntityType(), pairedConnections.toArray(new ConnectedEntityRef[pairedConnections.size()])); } public UUID getConnectingIndexId() { - return getIndexId( getConnectingEntity(), getConnectionType(), null, + return getIndexId( getSourceRefs(), getConnectionType(), null, pairedConnections.toArray(new ConnectedEntityRef[pairedConnections.size()])); } public ConnectionRefImpl getConnectionToConnectionEntity() { - return new ConnectionRefImpl( getConnectingEntity(), + return new ConnectionRefImpl( getSourceRefs(), new ConnectedEntityRefImpl( CONNECTION_ENTITY_CONNECTION_TYPE, CONNECTION_ENTITY_TYPE, getUuid() ) ); } @@ -365,8 +365,8 @@ public class ConnectionRefImpl implements ConnectionRef { public UUID[] getIndexIds() { List<ConnectedEntityRef> var = getPairedConnections(); - return getIndexIds( getConnectingEntity(), getConnectedEntity().getConnectionType(), - getConnectedEntity().getType(), var.toArray(new ConnectedEntityRef[var.size()])); + return getIndexIds( getSourceRefs(), getTargetRefs().getConnectionType(), + getTargetRefs().getType(), var.toArray(new ConnectedEntityRef[var.size()])); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0465628d/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java index 6b508b4..e1b2f5e 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java @@ -77,9 +77,9 @@ public class EntityConnectionsIT extends AbstractCoreIT { List<ConnectionRef> connections = r.getConnections(); assertNotNull( connections ); - assertEquals( 1, connections.size() ); - assertEquals( secondUserEntity.getUuid(), connections.get( 0 ).getConnectedEntity().getUuid() ); - assertEquals( firstUserEntity.getUuid(), connections.get( 0 ).getConnectingEntity().getUuid() ); + assertEquals(1, connections.size()); + assertEquals( secondUserEntity.getUuid(), connections.get( 0 ).getTargetRefs().getUuid() ); + assertEquals( firstUserEntity.getUuid(), connections.get( 0 ).getSourceRefs().getUuid() ); } @@ -268,10 +268,10 @@ public class EntityConnectionsIT extends AbstractCoreIT { List<ConnectionRef> connections = r.getConnections(); - assertNotNull( connections ); - assertEquals( 1, connections.size() ); - assertEquals( fourpeaks.getUuid(), connections.get( 0 ).getConnectedEntity().getUuid() ); - assertEquals( firstUserEntity.getUuid(), connections.get( 0 ).getConnectingEntity().getUuid() ); + assertNotNull(connections); + assertEquals(1, connections.size()); + assertEquals(fourpeaks.getUuid(), connections.get(0).getTargetRefs().getUuid()); + assertEquals(firstUserEntity.getUuid(), connections.get(0).getSourceRefs().getUuid()); // now check membership assertTrue( em.isConnectionMember( firstUserEntity, "likes", fourpeaks ) ); @@ -283,9 +283,9 @@ public class EntityConnectionsIT extends AbstractCoreIT { connections = r.getConnections(); assertNotNull( connections ); - assertEquals( 1, connections.size() ); - assertEquals( arrogantbutcher.getUuid(), connections.get( 0 ).getConnectedEntity().getUuid() ); - assertEquals( secondUserEntity.getUuid(), connections.get( 0 ).getConnectingEntity().getUuid() ); + assertEquals(1, connections.size()); + assertEquals( arrogantbutcher.getUuid(), connections.get( 0 ).getTargetRefs().getUuid() ); + assertEquals( secondUserEntity.getUuid(), connections.get( 0 ).getSourceRefs().getUuid() ); // now check membership assertTrue( em.isConnectionMember( secondUserEntity, "likes", arrogantbutcher ) ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0465628d/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java index 988aa56..ec3b86c 100644 --- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java +++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java @@ -515,7 +515,7 @@ public class ExportServiceImpl implements ExportService { List<ConnectionRef> connections = results.getConnections(); for ( ConnectionRef connectionRef : connections ) { - jg.writeObject( connectionRef.getConnectedEntity().getUuid() ); + jg.writeObject( connectionRef.getTargetRefs().getUuid() ); } jg.writeEndArray();
