cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2420 Modeler: search is not performed for Stored Procedures
Date Thu, 05 Apr 2018 12:49:32 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master fa7e3fac7 -> 67aad8a98


CAY-2420 Modeler: search is not performed for Stored Procedures


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

Branch: refs/heads/master
Commit: 67aad8a98b112a1cb00274196261a3903a49a8a6
Parents: fa7e3fa
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Thu Apr 5 15:49:24 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Thu Apr 5 15:49:24 2018 +0300

----------------------------------------------------------------------
 RELEASE-NOTES.txt                               |  1 +
 .../cayenne/modeler/action/FindAction.java      | 41 ++++++++++++++++++++
 .../cayenne/modeler/dialog/FindDialog.java      |  7 +---
 .../cayenne/modeler/util/CellRenderers.java     |  1 -
 4 files changed, 43 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/67aad8a9/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 834ae21..3dfbdbc 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -47,6 +47,7 @@ CAY-2397 Modeler: Unable to set enum:value as Entity qualifier
 CAY-2401 Modeler: NPE in ObjEntity sync action
 CAY-2405 Broken prefetch of entity with inheritance and attribute with custom java type
 CAY-2411 Wrong resolution of ExtendedType with ValueObjectType for inherited class
+CAY-2420 Modeler: search is not performed for Stored Procedures
 
 ----------------------------------
 Release: 4.1.M1

http://git-wip-us.apache.org/repos/asf/cayenne/blob/67aad8a9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
index 94070f5..0da14eb 100755
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
@@ -33,6 +33,8 @@ import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.map.ProcedureParameter;
 import org.apache.cayenne.map.ProcedureQueryDescriptor;
 import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.map.SQLTemplateDescriptor;
@@ -47,6 +49,8 @@ import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
 import org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent;
 import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
+import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
+import org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent;
 import org.apache.cayenne.modeler.event.QueryDisplayEvent;
 import org.apache.cayenne.modeler.event.RelationshipDisplayEvent;
 import org.apache.cayenne.modeler.util.CayenneAction;
@@ -88,6 +92,8 @@ public class FindAction extends CayenneAction {
         PRIORITY_BY_TYPE.put(ProcedureQueryDescriptor.class,13);
         PRIORITY_BY_TYPE.put(Embeddable.class,              14);
         PRIORITY_BY_TYPE.put(EmbeddableAttribute.class,     15);
+        PRIORITY_BY_TYPE.put(Procedure.class,               16);
+        PRIORITY_BY_TYPE.put(ProcedureParameter.class,      17);
     }
 
     public static String getActionName() {
@@ -145,6 +151,10 @@ public class FindAction extends CayenneAction {
             jumpToEmbeddableAttributeResult((EmbeddableAttribute)searchResultEntry.getObject(),
editor, domain);
         } else if (searchResultEntry.getObject() instanceof Attribute || searchResultEntry.getObject()
instanceof Relationship) {
             jumpToAttributeResult(searchResultEntry, editor, domain);
+        } else if (searchResultEntry.getObject() instanceof Procedure) {
+            jumpToProcedureResult((Procedure)searchResultEntry.getObject(), editor, domain);
+        } else if (searchResultEntry.getObject() instanceof ProcedureParameter) {
+            jumpToProcedureResult((ProcedureParameter)searchResultEntry.getObject(), editor,
domain);
         }
     }
 
@@ -156,6 +166,7 @@ public class FindAction extends CayenneAction {
             searchInEmbeddables(pattern, result, dataMap);
             searchInDbEntities(pattern, result, dataMap);
             searchInObjEntities(pattern, result, dataMap);
+            searchInProcedures(pattern, result, dataMap);
         }
         Collections.sort(result);
         return result;
@@ -221,6 +232,20 @@ public class FindAction extends CayenneAction {
         }
     }
 
+    private void searchInProcedures(Pattern pattern, List<SearchResultEntry> result,
DataMap dataMap) {
+        for (Procedure proc : dataMap.getProcedures()) {
+            if (match(proc.getName(), pattern)) {
+                result.add(new SearchResultEntry(proc, proc.getName()));
+            }
+
+            for(ProcedureParameter param : proc.getCallParameters()) {
+                if(match(param.getName(), pattern)) {
+                    result.add(new SearchResultEntry(param, proc.getName() + '.' + param.getName()));
+                }
+            }
+        }
+    }
+
     private void checkCatalogOrSchema(Pattern pattern, List<SearchResultEntry> paths,
DbEntity ent, String catalogOrSchema) {
         if (catalogOrSchema != null && !catalogOrSchema.isEmpty()) {
             if (match(catalogOrSchema, pattern)) {
@@ -307,6 +332,22 @@ public class FindAction extends CayenneAction {
         }
     }
 
+    private static void jumpToProcedureResult(Procedure procedure, EditorView editor, DataChannelDescriptor
domain) {
+        DataMap map = procedure.getDataMap();
+        buildAndSelectTreePath(map, procedure, editor);
+        ProcedureDisplayEvent event = new ProcedureDisplayEvent(editor.getProjectTreeView(),
procedure, map, domain);
+        editor.getProcedureView().currentProcedureChanged(event);
+    }
+
+    private static void jumpToProcedureResult(ProcedureParameter parameter, EditorView editor,
DataChannelDescriptor domain) {
+        Procedure procedure = parameter.getProcedure();
+        DataMap map = procedure.getDataMap();
+        buildAndSelectTreePath(map, procedure, editor);
+        ProcedureParameterDisplayEvent event =
+                new ProcedureParameterDisplayEvent(editor.getProjectTreeView(), parameter,
procedure, map, domain);
+        editor.getProcedureView().currentProcedureParameterChanged(event);
+    }
+
     /**
      * Builds a tree path for a given path and make selection in it
      */

http://git-wip-us.apache.org/repos/asf/cayenne/blob/67aad8a9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
index e0e30e7..d01d99c 100755
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
@@ -65,12 +65,7 @@ public class FindDialog extends CayenneController {
     }
 
     protected void initBindings() {
-        view.getOkButton().addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-                view.dispose();
-            }
-        });
+        view.getOkButton().addActionListener(e -> view.dispose());
 
         JTable table = view.getTable();
         table.setRowHeight(24);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/67aad8a9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
index 8a9e562..0ac0e41 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
@@ -49,7 +49,6 @@ import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
-import org.apache.cayenne.swing.components.image.FilteredIconFactory;
 import org.apache.cayenne.util.CayenneMapEntry;
 
 /**


Mime
View raw message