airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: allow search with * - AIRAVATA-1333
Date Thu, 10 Jul 2014 15:22:51 GMT
Repository: airavata
Updated Branches:
  refs/heads/master afdba81cc -> 78cd7b324


allow search with * - AIRAVATA-1333


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

Branch: refs/heads/master
Commit: 78cd7b3246aa2d9468efbe9f48b90cb3f6f1ecc4
Parents: afdba81
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Thu Jul 10 11:22:45 2014 -0400
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Thu Jul 10 11:22:45 2014 -0400

----------------------------------------------------------------------
 .../registry/jpa/resources/WorkerResource.java    | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/78cd7b32/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
index 34ffe1f..a044d66 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
@@ -540,7 +540,15 @@ public class WorkerResource extends AbstractResource {
             String query = "SELECT p from Project p WHERE ";
             if (filters != null && filters.size() != 0) {
                 for (String field : filters.keySet()) {
-                    query += "p." + field + " LIKE '%" + filters.get(field) + "%' AND ";
+                    String filterVal = filters.get(field);
+                    if (field.equals(ProjectConstants.USERNAME)) {
+                        query += "p." + field + "= '" + filterVal + "' AND ";
+                    } else {
+                        if (filterVal.contains("*")){
+                            filterVal = filterVal.replaceAll("\\*", "");
+                        }
+                        query += "p." + field + " LIKE '%" + filterVal + "%' AND ";
+                    }
                 }
             }
             query = query.substring(0, query.length() - 5);
@@ -576,10 +584,14 @@ public class WorkerResource extends AbstractResource {
             String query = "SELECT e from Experiment e WHERE ";
             if (filters != null && filters.size() != 0) {
                 for (String field : filters.keySet()) {
+                    String filterVal = filters.get(field);
                     if (field.equals(ExperimentConstants.EXECUTION_USER)) {
-                        query += "e." + field + "= '" + filters.get(field) + "' AND ";
+                        query += "e." + field + "= '" + filterVal + "' AND ";
                     } else {
-                        query += "e." + field + " LIKE '%" + filters.get(field) + "%' AND
";
+                        if (filterVal.contains("*")){
+                            filterVal = filterVal.replaceAll("\\*", "");
+                        }
+                        query += "e." + field + " LIKE '%" + filterVal + "%' AND ";
                     }
                 }
             }


Mime
View raw message