You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/04/15 01:01:22 UTC
[4/5] usergrid git commit: Fix issues when groups not being targeted
in notifications when referencing by name.
Fix issues when groups not being targeted in notifications when referencing by name.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/226cb62b
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/226cb62b
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/226cb62b
Branch: refs/heads/release-2.1.1
Commit: 226cb62b5c6ebf76741054d8a93e09265af21079
Parents: 99e6d40
Author: Michael Russo <mr...@apigee.com>
Authored: Fri Apr 15 00:48:01 2016 +0200
Committer: Michael Russo <mr...@apigee.com>
Committed: Fri Apr 15 00:48:01 2016 +0200
----------------------------------------------------------------------
.../corepersistence/CpRelationManager.java | 7 ++++++
.../apache/usergrid/persistence/PathQuery.java | 24 ++++++++++++++++++++
2 files changed, 31 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/226cb62b/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 b5a4107..9ecf466 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
@@ -945,6 +945,13 @@ public class CpRelationManager implements RelationManager {
query.setQl( newQuery );
}
+ // groups have a special unique identifier
+ else if ( query.getEntityType().equals( Group.ENTITY_TYPE ) ){
+
+ final String newQuery = "select * where path='" + query.getSingleNameOrEmailIdentifier() + "'";
+
+ query.setQl( newQuery );
+ }
// use the ident with the default alias. could be an email
else {
http://git-wip-us.apache.org/repos/asf/usergrid/blob/226cb62b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
index bb336e1..55839a6 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
@@ -17,10 +17,13 @@
package org.apache.usergrid.persistence;
+import java.util.Collections;
import java.util.Iterator;
import java.util.UUID;
import org.apache.usergrid.persistence.Query.Level;
+import org.apache.usergrid.persistence.index.query.Identifier;
+import org.apache.usergrid.utils.InflectionUtils;
public class PathQuery<E> {
@@ -85,6 +88,7 @@ public class PathQuery<E> {
public Iterator<E> iterator( EntityManager em ) {
try {
+
if ( uuid != null && type != null ) {
return new PagingResultsIterator( getHeadResults( em ), query.getResultsLevel() );
}
@@ -99,7 +103,20 @@ public class PathQuery<E> {
protected Results getHeadResults( EntityManager em ) throws Exception {
+
EntityRef ref = new SimpleEntityRef(type,uuid);
+
+ // if it's a single name identifier, just directly fetch that
+ if ( !query.getQl().isPresent() && query.getSingleNameOrEmailIdentifier() != null){
+
+ String name = query.getSingleNameOrEmailIdentifier();
+ String entityType = InflectionUtils.singularize(query.getCollection());
+
+ UUID entityId = em.getUniqueIdFromAlias( entityType, name );
+
+ return em.getEntities(Collections.singletonList(entityId), entityType);
+ }
+
return ( query.getCollection() != null ) ?
em.searchCollection( ref, query.getCollection(), query ) :
em.searchTargetEntities(ref, query);
@@ -107,6 +124,13 @@ public class PathQuery<E> {
protected Iterator refIterator( EntityManager em ) throws Exception {
+
+ if ( query.getQl() == null && query.getSingleNameOrEmailIdentifier() != null){
+
+ return new PagingResultsIterator( getHeadResults( em ), Level.REFS );
+
+ }
+
if ( type != null && uuid != null) {
return new PagingResultsIterator( getHeadResults( em ), Level.REFS );
}