cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1417068 - /cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
Date Tue, 04 Dec 2012 17:58:21 GMT
Author: aadamchik
Date: Tue Dec  4 17:58:20 2012
New Revision: 1417068

URL: http://svn.apache.org/viewvc?rev=1417068&view=rev
Log:
CAY-1708  Modeler error when pasting datamap with EJBQL querry

patch by Ilya Drabenia

Modified:
    cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java

Modified: cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java?rev=1417068&r1=1417067&r2=1417068&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
(original)
+++ cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
Tue Dec  4 17:58:20 2012
@@ -54,6 +54,7 @@ import org.apache.cayenne.modeler.undo.P
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.CayenneTransferable;
 import org.apache.cayenne.query.AbstractQuery;
+import org.apache.cayenne.query.EJBQLQuery;
 import org.apache.cayenne.query.Query;
 
 /**
@@ -294,36 +295,19 @@ public class PasteAction extends Cayenne
                         dataMap,
                         embeddable);
             }
+            else if (content instanceof EJBQLQuery) {
+                EJBQLQuery query = (EJBQLQuery) content;
+
+                query.setName(getFreeName(new QueryNameChecker(domain), query.getName()));
+                query.setDataMap(dataMap);
+
+                dataMap.addQuery(query);
+                QueryType.fireQueryEvent(this, mediator, dataMap, query);
+            }
             else if (content instanceof Query) {
                 // paste Query to DataMap
                 AbstractQuery query = (AbstractQuery) content;
 
-                /**
-                 * Change Query root do current datamap's
-                 */
-                Object root = query.getRoot();
-                Object newRoot = root;
-
-                if (root instanceof ObjEntity) {
-                    newRoot = dataMap.getObjEntity(((ObjEntity) root).getName());
-                }
-                else if (root instanceof DbEntity) {
-                    newRoot = dataMap.getDbEntity(((DbEntity) root).getName());
-                }
-                else if (root instanceof Procedure) {
-                    newRoot = dataMap.getProcedure(((Procedure) root).getName());
-                }
-
-                if (newRoot == null) {
-                    JOptionPane
-                            .showMessageDialog(
-                                    Application.getFrame(),
-                                    "Query root cannot be resolved. Pasting has not been
performed.",
-                                    "Warning",
-                                    JOptionPane.WARNING_MESSAGE);
-                    return;
-                }
-
                 query.setName(getFreeName(new QueryNameChecker(domain), query.getName()));
                 query.setDataMap(dataMap);
 



Mime
View raw message