airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: adding not operator to sharing registry
Date Mon, 06 Feb 2017 17:53:17 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop f71ef2139 -> a54f78133


adding not operator to sharing registry


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

Branch: refs/heads/develop
Commit: a54f78133d494b6f309963f2b39c7fd09c081118
Parents: f71ef21
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Mon Feb 6 12:53:05 2017 -0500
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Mon Feb 6 12:53:05 2017 -0500

----------------------------------------------------------------------
 .../db/repositories/EntityRepository.java       | 24 +++++++++++++++----
 .../registry/SharingRegistryServiceTest.java    | 10 ++++++--
 .../sharing/registry/models/Domain.java         | 25 ++++++++++++++++----
 .../registry/models/EntitySearchField.java      |  4 ++++
 .../registry/models/SearchCondition.java        |  5 +++-
 .../api-docs/sharing_models.html                |  6 +++++
 .../thrift_models/sharing_models.thrift         |  3 ++-
 7 files changed, 65 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/a54f7813/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 f445f36..b470f11 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
@@ -61,11 +61,19 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity,
E
 
         for(SearchCriteria searchCriteria : filters){
             if(searchCriteria.getSearchField().equals(EntitySearchField.NAME)){
-                query += "E.NAME LIKE '%" + searchCriteria.getValue() + "%' AND ";
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT))
{
+                    query += "E.NAME != '" + searchCriteria.getValue() + "' AND ";
+                } else {
+                    query += "E.NAME LIKE '%" + searchCriteria.getValue() + "%' AND ";
+                }
             }else if(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)){
                 query += "E.DESCRIPTION LIKE '%" + searchCriteria.getValue() + "%' AND ";
             }else if(searchCriteria.getSearchField().equals(EntitySearchField.PERMISSION_TYPE_ID)){
-                query += "S.PERMISSION_TYPE_ID = '" + searchCriteria.getValue() + "' AND
";
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT))
{
+                    query += "S.PERMISSION_TYPE_ID != '" + searchCriteria.getValue() + "'
AND ";
+                } else {
+                    query += "S.PERMISSION_TYPE_ID = '" + searchCriteria.getValue() + "'
AND ";
+                }
             }else if(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)){
                 try {
                     if(ServerSettings.getSetting(JPAUtils.SHARING_REG_JDBC_DRIVER).contains("derby")){
@@ -85,9 +93,17 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity,
E
                     throw new SharingRegistryException(e.getMessage());
                 }
             }else if(searchCriteria.getSearchField().equals(EntitySearchField.PARRENT_ENTITY_ID)){
-                query += "E.PARENT_ENTITY_ID = '" + searchCriteria.getValue() + "' AND ";
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT))
{
+                    query += "E.PARENT_ENTITY_ID != '" + searchCriteria.getValue() + "' AND
";
+                } else {
+                    query += "E.PARENT_ENTITY_ID = '" + searchCriteria.getValue() + "' AND
";
+                }
             }else if(searchCriteria.getSearchField().equals(EntitySearchField.OWNER_ID)){
-                query += "E.OWNER_ID = '" + searchCriteria.getValue() + "' AND ";
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT))
{
+                    query += "E.OWNER_ID != '" + searchCriteria.getValue() + "' AND ";
+                } else {
+                    query += "E.OWNER_ID = '" + searchCriteria.getValue() + "' AND ";
+                }
             }else if(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_TIME)){
                 if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
                     query += "E.CREATED_TIME >= " + Integer.parseInt(searchCriteria.getValue().trim())
+ " AND ";

http://git-wip-us.apache.org/repos/asf/airavata/blob/a54f7813/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 d289c46..655b7b5 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
@@ -28,7 +28,6 @@ import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TProtocol;
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
-import org.databene.contiperf.PerfTest;
 import org.databene.contiperf.junit.ContiPerfRule;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -55,7 +54,7 @@ public class SharingRegistryServiceTest {
 
 
     @Test
-    @PerfTest(invocations = 50, threads = 10)
+//    @PerfTest(invocations = 50, threads = 10)
     public void test() throws TException, InterruptedException {
         String serverHost = "localhost";
         int serverPort = 7878;
@@ -317,5 +316,12 @@ public class SharingRegistryServiceTest {
         Assert.assertEquals(entity3.getName(), persistedEntity.getName());
         Assert.assertEquals(entity3.getDescription(), persistedEntity.getDescription());
         Assert.assertEquals(entity3.getFullText(), persistedEntity.getFullText());
+
+        searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.NOT);
+        searchCriteria.setValue("test-user-1");
+        searchCriteria.setSearchField(EntitySearchField.OWNER_ID);
+        filters.add(searchCriteria);
+        Assert.assertTrue(sharingServiceClient.searchEntities(domainId, "test-user-2", "EXPERIMENT",
filters, 0, -1).size() == 0);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/a54f7813/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Domain.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Domain.java
b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Domain.java
index 1bcefc7..a0e89a5 100644
--- a/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Domain.java
+++ b/modules/sharing-registry/sharing-registry-stubs/src/main/java/org/apache/airavata/sharing/registry/models/Domain.java
@@ -6,15 +6,32 @@
  */
 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 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.Arrays;
 import javax.annotation.Generated;
-import java.util.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
 /**

http://git-wip-us.apache.org/repos/asf/airavata/blob/a54f7813/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 581efc3..5b0f66c 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
@@ -7,6 +7,10 @@
 package org.apache.airavata.sharing.registry.models;
 
 
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift.TEnum;
+
 /**
  * <p>This list of fields that can be used to search entities</p>
  * <li>NAME : Name of the entity</li>

http://git-wip-us.apache.org/repos/asf/airavata/blob/a54f7813/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 80b57e7..cd65078 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
@@ -25,7 +25,8 @@ public enum SearchCondition implements org.apache.thrift.TEnum {
   LIKE(1),
   FULL_TEXT(2),
   GTE(3),
-  LTE(4);
+  LTE(4),
+  NOT(5);
 
   private final int value;
 
@@ -56,6 +57,8 @@ public enum SearchCondition implements org.apache.thrift.TEnum {
         return GTE;
       case 4:
         return LTE;
+      case 5:
+        return NOT;
       default:
         return null;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/a54f7813/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 2bd64ee..d59f72b 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
@@ -108,6 +108,12 @@ considered as a group in it's own right for implementation ease</p>
 </td></tr>
 <tr><td><code>LTE</code></td><td><code>4</code></td><td>
 </td></tr>
+  <tr>
+   <td><code>NOT</code></td>
+   <td><code>5</code></td>
+   <td>
+   </td>
+  </tr>
 </table></div>
 <div class="definition"><h3 id="Enum_SharingType">Enumeration: SharingType</h3>
 <p>This is an internal enum type for managing sharings</p>

http://git-wip-us.apache.org/repos/asf/airavata/blob/a54f7813/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 3216208..d57eb09 100644
--- a/modules/sharing-registry/thrift_models/sharing_models.thrift
+++ b/modules/sharing-registry/thrift_models/sharing_models.thrift
@@ -179,7 +179,8 @@ enum SearchCondition {
     LIKE,
     FULL_TEXT,
     GTE,
-    LTE
+    LTE,
+    NOT
 }
 
 /**


Mime
View raw message