You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2017/04/03 16:50:01 UTC
[28/50] airavata git commit: adding capability to search based on the
shared_count
adding capability to search based on the shared_count
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/7e1d3695
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/7e1d3695
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/7e1d3695
Branch: refs/heads/master
Commit: 7e1d36953ae5f756ded7158460a278f0211d90ce
Parents: 0c8c2ae
Author: scnakandala <su...@gmail.com>
Authored: Mon Mar 20 23:31:39 2017 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Mon Mar 20 23:31:39 2017 -0400
----------------------------------------------------------------------
.../db/repositories/EntityRepository.java | 6 ++++
.../registry/SharingRegistryServiceTest.java | 13 ++++++--
.../sharing/registry/models/Entity.java | 32 +++++++++++++++-----
.../registry/models/EntitySearchField.java | 6 +++-
.../registry/models/SearchCondition.java | 4 +--
.../api-docs/sharing_models.html | 11 +++++--
.../thrift_models/sharing_models.thrift | 8 +++--
7 files changed, 63 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/7e1d3695/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
index 504a75b..15ac97a 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
@@ -121,6 +121,12 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, E
}else{
query += "E.UPDATED_TIME <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
}
+ } else if (searchCriteria.getSearchField().equals(EntitySearchField.SHARED_COUNT)) {
+ if (searchCriteria.getSearchCondition().equals(SearchCondition.GTE)) {
+ query += "E.SHARED_COUNT >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+ } else {
+ query += "E.SHARED_COUNT <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+ }
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7e1d3695/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
index 15a84c6..a8c177a 100644
--- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
@@ -281,6 +281,15 @@ public class SharingRegistryServiceTest {
Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 0);
sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 1);
+ ArrayList<SearchCriteria> filters = new ArrayList<>();
+ SearchCriteria searchCriteria = new SearchCriteria();
+ searchCriteria.setSearchField(EntitySearchField.SHARED_COUNT);
+ searchCriteria.setValue("1");
+ searchCriteria.setSearchCondition(SearchCondition.GTE);
+ filters.add(searchCriteria);
+ Assert.assertTrue(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size() == 1);
+
+
sharingServiceClient.revokeEntitySharingFromUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE");
Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 0);
sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
@@ -312,8 +321,8 @@ public class SharingRegistryServiceTest {
//false
Assert.assertFalse((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-file-1", "CLONE")));
- ArrayList<SearchCriteria> filters = new ArrayList<>();
- SearchCriteria searchCriteria = new SearchCriteria();
+ filters = new ArrayList<>();
+ searchCriteria = new SearchCriteria();
searchCriteria.setSearchCondition(SearchCondition.FULL_TEXT);
searchCriteria.setValue("experiment");
searchCriteria.setSearchField(EntitySearchField.FULL_TEXT);
http://git-wip-us.apache.org/repos/asf/airavata/blob/7e1d3695/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java
index 36fa51e..4dd9aa2 100644
--- a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java
+++ b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Entity.java
@@ -6,16 +6,34 @@
*/
package org.apache.airavata.sharing.registry.models;
-import org.apache.thrift.EncodingUtils;
-import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
-import org.apache.thrift.scheme.TupleScheme;
-import javax.annotation.Generated;
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
import java.nio.ByteBuffer;
-import java.util.*;
+import java.util.Arrays;
+import javax.annotation.Generated;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
/**
@@ -673,7 +691,7 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>,
if (value == null) {
unsetSharedCount();
} else {
- setSharedCount((Integer) value);
+ setSharedCount((Integer)value);
}
break;
@@ -681,7 +699,7 @@ public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>,
if (value == null) {
unsetOriginalEntityCreationTime();
} else {
- setOriginalEntityCreationTime((Long) value);
+ setOriginalEntityCreationTime((Long)value);
}
break;
http://git-wip-us.apache.org/repos/asf/airavata/blob/7e1d3695/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/EntitySearchField.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/EntitySearchField.java b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/EntitySearchField.java
index 91d245f..2486d4f 100644
--- a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/EntitySearchField.java
+++ b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/EntitySearchField.java
@@ -20,6 +20,7 @@ import org.apache.thrift.TEnum;
* <li>OWNER_ID : Owner of the entity</li>
* <li>CREATED_TIME : Created time of the entity</li>
* <li>UPDATED_TIME : Updated time of the entity</li>
+ * <li>SHARED_COUNT : Number of directly shared users and groups</li>
*
*/
public enum EntitySearchField implements org.apache.thrift.TEnum {
@@ -31,7 +32,8 @@ public enum EntitySearchField implements org.apache.thrift.TEnum {
PERMISSION_TYPE_ID(5),
CREATED_TIME(6),
UPDATED_TIME(7),
- ENTITY_TYPE_ID(8);
+ ENTITY_TYPE_ID(8),
+ SHARED_COUNT(9);
private final int value;
@@ -70,6 +72,8 @@ public enum EntitySearchField implements org.apache.thrift.TEnum {
return UPDATED_TIME;
case 8:
return ENTITY_TYPE_ID;
+ case 9:
+ return SHARED_COUNT;
default:
return null;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7e1d3695/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/SearchCondition.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/SearchCondition.java b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/SearchCondition.java
index cd65078..bdeb721 100644
--- a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/SearchCondition.java
+++ b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/SearchCondition.java
@@ -16,8 +16,8 @@ import org.apache.thrift.TEnum;
* <li>EQUAL : Simply matches for equality. Applicable for name, and parent entity id</li>
* <li>LIKE : Check for the condition %$FIELD% condition. Applicable for name, and description</li>
* <li>FULL_TEXT : Does a full text search. Only applicable for the FULL_TEXT field.</li>
- * <li>GTE : Greater than or equal. Only applicable for created time and updated time.</li>
- * <li>LTE : Less than or equal. Only applicable for created time and updated time.</li>
+ * <li>GTE : Greater than or equal. Only applicable for created time, updated time and shared count.</li>
+ * <li>LTE : Less than or equal. Only applicable for created time, updated time and shared count.</li>
*
*/
public enum SearchCondition implements org.apache.thrift.TEnum {
http://git-wip-us.apache.org/repos/asf/airavata/blob/7e1d3695/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html b/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html
index e49d79e..3937299 100644
--- a/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html
+++ b/modules/sharing-registry/sharing-service-docs/api-docs/sharing_models.html
@@ -70,6 +70,7 @@ considered as a group in it's own right for implementation ease</p>
<li>OWNER_ID : Owner of the entity</li>
<li>CREATED_TIME : Created time of the entity</li>
<li>UPDATED_TIME : Updated time of the entity</li>
+ <li>SHARED_COUNT : Number of directly shared users and groups</li>
<br/><br/><table class="table-bordered table-striped table-condensed">
<tr><td><code>NAME</code></td><td><code>0</code></td><td>
@@ -94,14 +95,20 @@ considered as a group in it's own right for implementation ease</p>
<td>
</td>
</tr>
+ <tr>
+ <td><code>SHARED_COUNT</code></td>
+ <td><code>9</code></td>
+ <td>
+ </td>
+ </tr>
</table></div>
<div class="definition"><h3 id="Enum_SearchCondition">Enumeration: SearchCondition</h3>
<p>Different search operators that can be used with the entity search fields</p>
<li>EQUAL : Simply matches for equality. Applicable for name, and parent entity id</li>
<li>LIKE : Check for the condition %$FIELD% condition. Applicable for name, and description</li>
<li>FULL_TEXT : Does a full text search. Only applicable for the FULL_TEXT field.</li>
-<li>GTE : Greater than or equal. Only applicable for created time and updated time.</li>
-<li>LTE : Less than or equal. Only applicable for created time and updated time.</li>
+ <li>GTE : Greater than or equal. Only applicable for created time, updated time and shared count.</li>
+ <li>LTE : Less than or equal. Only applicable for created time, updated time and shared count.</li>
<br/><br/><table class="table-bordered table-striped table-condensed">
<tr><td><code>EQUAL</code></td><td><code>0</code></td><td>
http://git-wip-us.apache.org/repos/asf/airavata/blob/7e1d3695/modules/sharing-registry/thrift_models/sharing_models.thrift
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/thrift_models/sharing_models.thrift b/modules/sharing-registry/thrift_models/sharing_models.thrift
index 977a1fd..50518e1 100644
--- a/modules/sharing-registry/thrift_models/sharing_models.thrift
+++ b/modules/sharing-registry/thrift_models/sharing_models.thrift
@@ -154,6 +154,7 @@ struct EntityType {
* <li>OWNER_ID : Owner of the entity</li>
* <li>CREATED_TIME : Created time of the entity</li>
* <li>UPDATED_TIME : Updated time of the entity</li>
+* <li>SHARED_COUNT : Number of directly shared users and groups</li>
**/
enum EntitySearchField {
NAME,
@@ -164,7 +165,8 @@ enum EntitySearchField {
PERMISSION_TYPE_ID,
CREATED_TIME,
UPDATED_TIME,
- ENTITY_TYPE_ID
+ ENTITY_TYPE_ID,
+ SHARED_COUNT
}
/**
@@ -172,8 +174,8 @@ enum EntitySearchField {
* <li>EQUAL : Simply matches for equality. Applicable for name, and parent entity id</li>
* <li>LIKE : Check for the condition %$FIELD% condition. Applicable for name, and description</li>
* <li>FULL_TEXT : Does a full text search. Only applicable for the FULL_TEXT field.</li>
-* <li>GTE : Greater than or equal. Only applicable for created time and updated time.</li>
-* <li>LTE : Less than or equal. Only applicable for created time and updated time.</li>
+* <li>GTE : Greater than or equal. Only applicable for created time, updated time and shared count.</li>
+* <li>LTE : Less than or equal. Only applicable for created time, updated time and shared count.</li>
**/
enum SearchCondition {
EQUAL,