cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [1/3] cayenne git commit: procedure catalog support
Date Wed, 20 Apr 2016 08:06:21 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 3a7e93142 -> 9a959583a


procedure catalog support


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

Branch: refs/heads/master
Commit: f48fb182d76dc3dbb5d807bbc03999a1749d12bc
Parents: 2770701
Author: olga <ollybondareva@gmail.com>
Authored: Wed Apr 6 13:44:39 2016 +0300
Committer: olga <ollybondareva@gmail.com>
Committed: Fri Apr 8 14:01:15 2016 +0300

----------------------------------------------------------------------
 .../java/org/apache/cayenne/map/Procedure.java  |  6 ++-
 .../org/apache/cayenne/schema/8/modelMap.xsd    |  2 +
 .../modeler/action/CreateProcedureAction.java   |  1 +
 .../cayenne/modeler/editor/ProcedureTab.java    | 47 +++++++++++++-------
 4 files changed, 38 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/f48fb182/cayenne-server/src/main/java/org/apache/cayenne/map/Procedure.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/Procedure.java b/cayenne-server/src/main/java/org/apache/cayenne/map/Procedure.java
index 356e1c2..d411f58 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/Procedure.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/Procedure.java
@@ -121,10 +121,12 @@ public class Procedure implements ConfigurationNode, CayenneMapEntry,
XMLSeriali
     }
 
     /**
-     * Returns procedure name including schema, if present.
+     * Returns procedure name including schema and catalog, if present.
      */
     public String getFullyQualifiedName() {
-        return (schema != null) ? schema + '.' + getName() : getName();
+        return (catalog != null ? catalog + '.' : "")
+                + (schema != null ? schema + '.' : "")
+                + name;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f48fb182/cayenne-server/src/main/resources/org/apache/cayenne/schema/8/modelMap.xsd
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/resources/org/apache/cayenne/schema/8/modelMap.xsd b/cayenne-server/src/main/resources/org/apache/cayenne/schema/8/modelMap.xsd
index 37f0f91..3d77151 100644
--- a/cayenne-server/src/main/resources/org/apache/cayenne/schema/8/modelMap.xsd
+++ b/cayenne-server/src/main/resources/org/apache/cayenne/schema/8/modelMap.xsd
@@ -269,6 +269,8 @@
 			</xs:sequence>
 			<xs:attribute name="name" use="required" type="xs:string"/>
 			<xs:attribute name="schema" type="xs:string"/>
+			<xs:attribute name="catalog" type="xs:string"/>
+			<xs:attribute name="returningValue" type="xs:string"/>
 		</xs:complexType>
 	</xs:element>
 	<xs:element name="pre-update">

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f48fb182/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java
index 830ebca..1c5397f 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java
@@ -71,6 +71,7 @@ public class CreateProcedureAction extends CayenneAction {
 	public void createProcedure(DataMap map, Procedure procedure) {
 		ProjectController mediator = getProjectController();
 		procedure.setSchema(map.getDefaultSchema());
+		procedure.setCatalog(map.getDefaultCatalog());
 		map.addProcedure(procedure);
 		fireProcedureEvent(this, mediator, map, procedure);
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f48fb182/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
index 041c04a..476beb8 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
@@ -29,6 +29,7 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 
+import com.jgoodies.forms.builder.DefaultFormBuilder;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.event.ProcedureEvent;
 import org.apache.cayenne.map.Procedure;
@@ -40,8 +41,6 @@ import org.apache.cayenne.modeler.util.TextAdapter;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.validation.ValidationException;
 
-import com.jgoodies.forms.builder.PanelBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
 import com.jgoodies.forms.layout.FormLayout;
 
 /**
@@ -54,6 +53,7 @@ public class ProcedureTab extends JPanel implements ProcedureDisplayListener,
Ex
     protected ProjectController eventController;
     protected TextAdapter name;
     protected TextAdapter schema;
+    protected TextAdapter catalog;
     protected JCheckBox returnsValue;
     protected boolean ignoreChange;
 
@@ -81,27 +81,28 @@ public class ProcedureTab extends JPanel implements ProcedureDisplayListener,
Ex
             }
         };
 
-        this.returnsValue = new JCheckBox();
+        this.catalog = new TextAdapter(new JTextField()) {
+
+            protected void updateModel(String text) {
+                setCatalog(text);
+            }
+        };
 
         JLabel returnValueHelp = new JLabel("(first parameter will be used as return value)");
         returnValueHelp.setFont(returnValueHelp.getFont().deriveFont(10));
 
-        // assemble
-        FormLayout layout = new FormLayout("right:max(50dlu;pref), 3dlu, left:max(20dlu;pref),
3dlu, fill:150dlu",
-                "p, 3dlu, p, 3dlu, p, 3dlu, p");
+        this.returnsValue = new JCheckBox();
+        this.returnsValue.setToolTipText(returnValueHelp.getText());
 
-        CellConstraints cc = new CellConstraints();
-        PanelBuilder builder = new PanelBuilder(layout);
+        FormLayout layout = new FormLayout("right:pref, 3dlu, fill:200dlu", "");
+        DefaultFormBuilder builder = new DefaultFormBuilder(layout);
         builder.setDefaultDialogBorder();
 
-        builder.addSeparator("Stored Procedure Configuration", cc.xywh(1, 1, 5, 1));
-        builder.addLabel("Procedure Name:", cc.xy(1, 3));
-        builder.add(name.getComponent(), cc.xywh(3, 3, 3, 1));
-        builder.addLabel("Schema:", cc.xy(1, 5));
-        builder.add(schema.getComponent(), cc.xywh(3, 5, 3, 1));
-        builder.addLabel("Returns Value:", cc.xy(1, 7));
-        builder.add(returnsValue, cc.xy(3, 7));
-        builder.add(returnValueHelp, cc.xy(5, 7));
+        builder.appendSeparator("Stored Procedure Configuration");
+        builder.append("Procedure Name:", name.getComponent());
+        builder.append("Schema:", schema.getComponent());
+        builder.append("Catalog:", catalog.getComponent());
+        builder.append("Returns Value:", returnsValue);
 
         this.setLayout(new BorderLayout());
         this.add(builder.getPanel(), BorderLayout.CENTER);
@@ -139,6 +140,7 @@ public class ProcedureTab extends JPanel implements ProcedureDisplayListener,
Ex
 
         name.setText(procedure.getName());
         schema.setText(procedure.getSchema());
+        catalog.setText(procedure.getCatalog());
 
         ignoreChange = true;
         returnsValue.setSelected(procedure.isReturningValue());
@@ -181,4 +183,17 @@ public class ProcedureTab extends JPanel implements ProcedureDisplayListener,
Ex
             eventController.fireProcedureEvent(new ProcedureEvent(this, procedure));
         }
     }
+
+    void setCatalog(String text) {
+        if (text != null && text.trim().length() == 0) {
+            text = null;
+        }
+
+        Procedure procedure = eventController.getCurrentProcedure();
+
+        if (procedure != null && !Util.nullSafeEquals(procedure.getCatalog(), text))
{
+            procedure.setCatalog(text);
+            eventController.fireProcedureEvent(new ProcedureEvent(this, procedure));
+        }
+    }
 }


Mime
View raw message