minor, cube draft provides fuzzy search

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

Branch: refs/heads/master
Commit: c6ade2f0385f69bd1be90fd57de5e31cffde5f16
Parents: 3f9d158
Author: Roger Shi <[email protected]>
Authored: Thu Jun 22 13:44:00 2017 +0800
Committer: Hongbin Ma <[email protected]>
Committed: Fri Jun 23 19:14:31 2017 +0800

----------------------------------------------------------------------
 .../apache/kylin/rest/controller2/CubeControllerV2.java   |  2 +-
 .../kylin/rest/controller2/ProjectControllerV2.java       |  2 +-
 .../java/org/apache/kylin/rest/service/CubeService.java   | 10 ++++++----
 3 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/c6ade2f0/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
 
b/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
index 93c4d4e..63f2d8e 100644
--- 
a/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
+++ 
b/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
@@ -113,7 +113,7 @@ public class CubeControllerV2 extends BasicController {
         }
         
         // draft cubes
-        for (Draft d : cubeService.listCubeDrafts(cubeName, modelName, 
projectName)) {
+        for (Draft d : cubeService.listCubeDrafts(cubeName, modelName, 
projectName, exactMatch)) {
             CubeDesc c = (CubeDesc) d.getEntity();
             if (contains(response, c.getName()) == false) {
                 CubeInstanceResponse r = 
createCubeInstanceResponseFromDraft(d);

http://git-wip-us.apache.org/repos/asf/kylin/blob/c6ade2f0/server-base/src/main/java/org/apache/kylin/rest/controller2/ProjectControllerV2.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/controller2/ProjectControllerV2.java
 
b/server-base/src/main/java/org/apache/kylin/rest/controller2/ProjectControllerV2.java
index 5a34807..6dea4e3 100644
--- 
a/server-base/src/main/java/org/apache/kylin/rest/controller2/ProjectControllerV2.java
+++ 
b/server-base/src/main/java/org/apache/kylin/rest/controller2/ProjectControllerV2.java
@@ -168,7 +168,7 @@ public class ProjectControllerV2 extends BasicController {
 
     private boolean isProjectEmpty(String projectName) throws IOException {
         return cubeService.listAllCubes(projectName).isEmpty()
-                && cubeService.listCubeDrafts(null, null, 
projectName).isEmpty()
+                && cubeService.listCubeDrafts(null, null, projectName, 
true).isEmpty()
                 && modelService.listAllModels(null, projectName, 
false).isEmpty()
                 && modelService.listModelDrafts(null, projectName).isEmpty();
     }

http://git-wip-us.apache.org/repos/asf/kylin/blob/c6ade2f0/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
index f6de877..ea5378f 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
@@ -649,21 +649,23 @@ public class CubeService extends BasicService {
     }
 
     public Draft getCubeDraft(String cubeName) throws IOException {
-        for (Draft d : listCubeDrafts(cubeName, null, null)) {
+        for (Draft d : listCubeDrafts(cubeName, null, null, true)) {
             return d;
         }
         return null;
     }
 
-    public List<Draft> listCubeDrafts(String cubeName, String modelName, 
String project) throws IOException {
+    public List<Draft> listCubeDrafts(String cubeName, String modelName, 
String project, boolean exactMatch)
+            throws IOException {
         List<Draft> result = new ArrayList<>();
 
         for (Draft d : getDraftManager().list(project)) {
             RootPersistentEntity e = d.getEntity();
             if (e instanceof CubeDesc) {
                 CubeDesc c = (CubeDesc) e;
-                if ((cubeName == null || cubeName.equals(c.getName()))
-                        && (modelName == null || 
modelName.equals(c.getModelName()))) {
+                if ((cubeName == null || (exactMatch && 
cubeName.toLowerCase().equals(c.getName().toLowerCase()))
+                        || (!exactMatch && 
c.getName().toLowerCase().contains(cubeName.toLowerCase())))
+                        && (modelName == null || 
modelName.toLowerCase().equals(c.getModelName().toLowerCase()))) {
                     result.add(d);
                 }
             }

Reply via email to