Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CAY-1708 Modeler error when pasting datamap with EJBQL querry

patch by Ilya Drabenia

git-svn-id: https://svn.apache.org/repos/asf/cayenne/main/trunk@1417063 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit af3b7fb9c95a3e04bf2128056ffd3450163e0ea5 1 parent 8e1d7b4
@andrus andrus authored
View
36 modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
@@ -54,6 +54,7 @@
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 @@ else if (content instanceof Embeddable) {
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);

0 comments on commit af3b7fb

Please sign in to comment.
Something went wrong with that request. Please try again.