cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r905616 [5/6] - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/event/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ cayenne-jdk1.5-unpublished/src/main/java/org/apach...
Date Tue, 02 Feb 2010 13:08:18 GMT
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/ObjGraphBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/ObjGraphBuilder.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/ObjGraphBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/ObjGraphBuilder.java Tue Feb  2 13:06:56 2010
@@ -23,9 +23,10 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.Entity;
+import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.event.AttributeEvent;
 import org.apache.cayenne.map.event.EntityEvent;
@@ -41,59 +42,64 @@
 /**
  * Builder of ObjEntity information-based graph (relative to UML class diagram)
  */
-class ObjGraphBuilder extends BaseGraphBuilder
-    implements ObjEntityListener, ObjAttributeListener, ObjRelationshipListener {
-    
+class ObjGraphBuilder extends BaseGraphBuilder implements ObjEntityListener,
+        ObjAttributeListener, ObjRelationshipListener {
+
     static final Color ENTITY_COLOR = new Color(255, 255, 185);
-    
+
     Map<Entity, DefaultEdge> inheritanceEdges;
-    
+
     public ObjGraphBuilder() {
         inheritanceEdges = new HashMap<Entity, DefaultEdge>();
     }
-    
+
     @Override
     protected Collection<? extends Entity> getEntities(DataMap map) {
         return map.getObjEntities();
     }
 
     @Override
-    protected boolean isIsolated(DataDomain domain, Entity entity) {
-        return super.isIsolated(domain, entity) && 
-            ((ObjEntity) entity).getSuperEntity() == null && 
-             domain.getEntityResolver().lookupInheritanceTree(entity.getName()) == null;
+    protected boolean isIsolated(DataChannelDescriptor domain, Entity entity) {
+        EntityResolver entRes = new EntityResolver(((DataChannelDescriptor)mediator.getProject().getRootNode()).getDataMaps());
+        return super.isIsolated(domain, entity)
+                && ((ObjEntity) entity).getSuperEntity() == null
+                && entRes.lookupInheritanceTree(entity.getName()) == null;
     }
-    
+
     @Override
     protected void postProcessEntity(Entity entity, DefaultGraphCell cell) {
         super.postProcessEntity(entity, cell);
-        
+
         GraphConstants.setBackground(cell.getAttributes(), ENTITY_COLOR);
         GraphConstants.setOpaque(cell.getAttributes(), true);
-        
+
         DefaultEdge edge = createInheritanceEdge((ObjEntity) entity);
         if (edge != null) {
             createdObjects.add(edge);
         }
     }
-    
+
     DefaultEdge createInheritanceEdge(ObjEntity entity) {
         if (!inheritanceEdges.containsKey(entity)) {
             ObjEntity superEntity = entity.getSuperEntity();
             if (superEntity != null) {
                 DefaultGraphCell sourceCell = entityCells.get(entity.getName());
                 DefaultGraphCell targetCell = entityCells.get(superEntity.getName());
-                
+
                 DefaultEdge edge = new DefaultEdge();
                 edge.setSource(sourceCell.getChildAt(0));
                 edge.setTarget(targetCell.getChildAt(0));
-                
-                GraphConstants.setDashPattern(edge.getAttributes(), new float[] { 5, 5 });
-                GraphConstants.setLineEnd(edge.getAttributes(), GraphConstants.ARROW_TECHNICAL);
+
+                GraphConstants.setDashPattern(edge.getAttributes(), new float[] {
+                        5, 5
+                });
+                GraphConstants.setLineEnd(
+                        edge.getAttributes(),
+                        GraphConstants.ARROW_TECHNICAL);
                 GraphConstants.setSelectable(edge.getAttributes(), false);
-                
+
                 inheritanceEdges.put(entity, edge);
-                
+
                 return edge;
             }
         }
@@ -104,11 +110,11 @@
     protected EntityCellMetadata getCellMetadata(Entity e) {
         return new ObjEntityCellMetadata(this, e.getName());
     }
-    
+
     @Override
     public void setProjectController(ProjectController mediator) {
         super.setProjectController(mediator);
-        
+
         mediator.addObjEntityListener(this);
         mediator.addObjAttributeListener(this);
         mediator.addObjRelationshipListener(this);
@@ -116,91 +122,78 @@
 
     public void destroy() {
         super.destroy();
-        
+
         mediator.removeObjEntityListener(this);
         mediator.removeObjAttributeListener(this);
         mediator.removeObjRelationshipListener(this);
     }
 
     public void objEntityAdded(EntityEvent e) {
-        if (isInCurrentDomain()) {
-            insertEntityCell(e.getEntity());
-        }
+        insertEntityCell(e.getEntity());
     }
 
     public void objEntityChanged(EntityEvent e) {
-        if (isInCurrentDomain()) {
-            remapEntity(e);
-            
-            updateEntityCell(e.getEntity());
-            
-            //maybe super entity was changed
-            ObjEntity entity = (ObjEntity) e.getEntity();
-            DefaultEdge inheritanceEdge = inheritanceEdges.get(entity);
-            if (inheritanceEdge != null) {
-                if (entity.getSuperEntity() == null) {
-                    graph.getGraphLayoutCache().remove(new Object[] { inheritanceEdge });
-                    inheritanceEdges.remove(entity);
-                }
-                else {
-                    inheritanceEdge.setTarget(entityCells.get(entity.getSuperEntity().getName()).getChildAt(0));
-                    
-                    Map nested = new HashMap();
-                    nested.put(inheritanceEdge, inheritanceEdge.getAttributes());
-                    
-                    graph.getGraphLayoutCache().edit(nested);
-                }
+        remapEntity(e);
+
+        updateEntityCell(e.getEntity());
+
+        // maybe super entity was changed
+        ObjEntity entity = (ObjEntity) e.getEntity();
+        DefaultEdge inheritanceEdge = inheritanceEdges.get(entity);
+        if (inheritanceEdge != null) {
+            if (entity.getSuperEntity() == null) {
+                graph.getGraphLayoutCache().remove(new Object[] {
+                    inheritanceEdge
+                });
+                inheritanceEdges.remove(entity);
             }
             else {
-                if (entity.getSuperEntity() != null) {
-                    DefaultEdge edge = createInheritanceEdge(entity);
-                    graph.getGraphLayoutCache().insert(edge);
-                }
+                inheritanceEdge.setTarget(entityCells.get(
+                        entity.getSuperEntity().getName()).getChildAt(0));
+
+                Map nested = new HashMap();
+                nested.put(inheritanceEdge, inheritanceEdge.getAttributes());
+
+                graph.getGraphLayoutCache().edit(nested);
+            }
+        }
+        else {
+            if (entity.getSuperEntity() != null) {
+                DefaultEdge edge = createInheritanceEdge(entity);
+                graph.getGraphLayoutCache().insert(edge);
             }
         }
     }
 
     public void objEntityRemoved(EntityEvent e) {
-        if (isInCurrentDomain()) {
-            removeEntityCell(e.getEntity());
-        }
+        removeEntityCell(e.getEntity());
     }
 
     public void objAttributeAdded(AttributeEvent e) {
-        if (isInCurrentDomain()) {
-            updateEntityCell(e.getEntity());
-        }
+        updateEntityCell(e.getEntity());
     }
 
     public void objAttributeChanged(AttributeEvent e) {
-        if (isInCurrentDomain()) {
-            updateEntityCell(e.getEntity());
-        }
+        updateEntityCell(e.getEntity());
     }
 
     public void objAttributeRemoved(AttributeEvent e) {
-        if (isInCurrentDomain()) {
-            updateEntityCell(e.getEntity());
-        }
+        updateEntityCell(e.getEntity());
     }
 
     public void objRelationshipAdded(RelationshipEvent e) {
-        //nothing because relationship does not have target yet
+        // nothing because relationship does not have target yet
     }
 
     public void objRelationshipChanged(RelationshipEvent e) {
-        if (isInCurrentDomain()) {
-            remapRelationship(e);
-            updateRelationshipCell(e.getRelationship());
-        }
+        remapRelationship(e);
+        updateRelationshipCell(e.getRelationship());
     }
 
     public void objRelationshipRemoved(RelationshipEvent e) {
-        if (isInCurrentDomain()) {
-            removeRelationshipCell(e.getRelationship());
-        }
+        removeRelationshipCell(e.getRelationship());
     }
-    
+
     @Override
     protected void removeEntityCell(Entity e) {
         super.removeEntityCell(e);

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/EntityDisplayAction.java Tue Feb  2 13:06:56 2010
@@ -23,6 +23,7 @@
 import javax.swing.Action;
 import javax.swing.Icon;
 
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
@@ -87,7 +88,7 @@
         
         //we're always in same domain
         FindDialog.jumpToResult(new Object[] { 
-                Application.getProject(), mediator.getCurrentDataDomain(), entity.getDataMap(), entity
+                Application.getProject(), (DataChannelDescriptor)mediator.getProject().getRootNode(), entity.getDataMap(), entity
         });
         
         return true;

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/ShowGraphEntityAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/ShowGraphEntityAction.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/ShowGraphEntityAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/action/ShowGraphEntityAction.java Tue Feb  2 13:06:56 2010
@@ -20,6 +20,7 @@
 
 import java.awt.event.ActionEvent;
 
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.CayenneModelerFrame;
@@ -82,7 +83,7 @@
                 editor.getProjectTreeView(),
                 entity,
                 entity.getDataMap(),
-                getProjectController().getCurrentDataDomain());
+                (DataChannelDescriptor)getProjectController().getProject().getRootNode());
         getProjectController().fireDomainDisplayEvent(event);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java Tue Feb  2 13:06:56 2010
@@ -41,7 +41,7 @@
 
     public String getLocalDataSource() {
         if(localDataSource == null){
-            localDataSource = getCurrentPreference().get(LOCAL_DATA_SOURCE_PROPERTY, null);
+            localDataSource = getCurrentPreference().get(LOCAL_DATA_SOURCE_PROPERTY, "");
         }
         return localDataSource;
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateAttributeUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateAttributeUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateAttributeUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateAttributeUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -21,7 +21,7 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -47,7 +47,7 @@
 	private ObjEntity objEntity;
 	private ObjAttribute objAttr;
 
-	private DataDomain domain;
+	private DataChannelDescriptor domain;
 	private DataMap dataMap;
 
 	private DbEntity dbEntity;
@@ -59,11 +59,11 @@
 				.getAction(CreateAttributeAction.getActionName());
 
 		if (objEntity != null) {
-			action.createObjAttribute(domain, dataMap, objEntity, objAttr);
+			action.createObjAttribute(dataMap, objEntity, objAttr);
 		}
 
 		if (dbEntity != null) {
-			action.createDbAttribute(domain, dataMap, dbEntity, dbAttr);
+			action.createDbAttribute(dataMap, dbEntity, dbAttr);
 		}
 	}
 
@@ -95,7 +95,7 @@
 		}
 	}
 
-	public CreateAttributeUndoableEdit(DataDomain domain, DataMap map,
+	public CreateAttributeUndoableEdit(DataChannelDescriptor domain, DataMap map,
 			ObjEntity objEntity, ObjAttribute attr) {
 		this.domain = domain;
 		this.dataMap = map;
@@ -103,7 +103,7 @@
 		this.objAttr = attr;
 	}
 
-	public CreateAttributeUndoableEdit(DataDomain domain, DataMap map,
+	public CreateAttributeUndoableEdit(DataChannelDescriptor domain, DataMap map,
 			DbEntity dbEntity, DbAttribute attr) {
 		this.domain = domain;
 		this.dataMap = map;

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -21,7 +21,7 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.action.CreateDataMapAction;
 import org.apache.cayenne.modeler.action.RemoveAction;
@@ -36,10 +36,10 @@
 
 	
 
-	private DataDomain domain;
+	private DataChannelDescriptor domain;
 	private DataMap map;
 
-	public CreateDataMapUndoableEdit(DataDomain domain, DataMap map) {
+	public CreateDataMapUndoableEdit(DataChannelDescriptor domain, DataMap map) {
 		this.domain = domain;
 		this.map = map;
 	}
@@ -48,7 +48,7 @@
 	public void redo() throws CannotRedoException {
 		CreateDataMapAction action = (CreateDataMapAction) actionManager
 				.getAction(CreateDataMapAction.getActionName());
-		action.createDataMap(domain, map);
+		action.createDataMap(map);
 	}
 
 	@Override
@@ -57,6 +57,6 @@
 		
 		controller.fireDomainDisplayEvent(new DomainDisplayEvent(this, domain));
 		
-		action.removeDataMap(domain, map);
+		action.removeDataMap(map);
 	}
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -21,8 +21,8 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.action.CreateNodeAction;
 import org.apache.cayenne.modeler.action.RemoveAction;
@@ -34,14 +34,11 @@
         return "Create DataNode";
     }
 
-    
+    private DataNodeDescriptor node;
+    private DataChannelDescriptor domain;
 
-    private DataNode node;
-    private DataDomain domain;
-
-    public CreateNodeUndoableEdit(Application application, DataDomain domain,
-            DataNode node) {
-        this.domain = domain;
+    public CreateNodeUndoableEdit(Application application, DataNodeDescriptor node) {
+        this.domain = (DataChannelDescriptor)application.getProject().getRootNode();;
         this.node = node;
     }
 
@@ -49,14 +46,13 @@
     public void undo() throws CannotUndoException {
         RemoveAction action = (RemoveAction) actionManager.getAction(RemoveAction
                 .getActionName());
-        action.removeDataNode(domain, node);
+        action.removeDataNode(node);
     }
 
-    @Override
     public void redo() throws CannotRedoException {
-        domain.addNode(node);
+        domain.getNodeDescriptors().add(node);
         CreateNodeAction action = (CreateNodeAction) actionManager
                 .getAction(CreateNodeAction.getActionName());
-        action.createDataNode(domain, node);
+        action.createDataNode(node);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -21,7 +21,7 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.action.CreateQueryAction;
 import org.apache.cayenne.modeler.action.RemoveAction;
@@ -29,13 +29,11 @@
 
 public class CreateQueryUndoableEdit extends CayenneUndoableEdit {
 
-    
-
-    private DataDomain domain;
+    private DataChannelDescriptor domain;
     private DataMap map;
     private Query query;
 
-    public CreateQueryUndoableEdit(DataDomain domain, DataMap map, Query query) {
+    public CreateQueryUndoableEdit(DataChannelDescriptor domain, DataMap map, Query query) {
         this.domain = domain;
         this.map = map;
         this.query = query;

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -21,6 +21,7 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.ObjEntity;
@@ -81,13 +82,13 @@
                     this,
                     objEnt,
                     objEnt.getDataMap(),
-                    controller.getCurrentDataDomain()));
+                    (DataChannelDescriptor)controller.getProject().getRootNode()));
         }
 
         if (dbEnt != null) {
             action.removeDbRelationships(dbEnt, dbRel);
             controller.fireDbEntityDisplayEvent(new EntityDisplayEvent(this, dbEnt, dbEnt
-                    .getDataMap(), controller.getCurrentDataDomain()));
+                    .getDataMap(), (DataChannelDescriptor)controller.getProject().getRootNode()));
         }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/DbEntitySyncUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/DbEntitySyncUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/DbEntitySyncUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/DbEntitySyncUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -22,7 +22,7 @@
 
 import javax.swing.undo.CompoundEdit;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.ObjAttribute;
@@ -42,10 +42,10 @@
         return !edits.isEmpty();
     }
 
-    private DataDomain domain;
+    private DataChannelDescriptor domain;
     private DataMap map;
 
-    public DbEntitySyncUndoableEdit(DataDomain domain, DataMap map) {
+    public DbEntitySyncUndoableEdit(DataChannelDescriptor domain, DataMap map) {
         super();
         this.domain = domain;
         this.map = map;

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -21,8 +21,8 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -43,12 +43,12 @@
 
     
 
-    private DataDomain domain;
+    private DataChannelDescriptor domain;
     private DataMap map;
     private Object where;
     private Object content;
 
-    public PasteUndoableEdit(DataDomain domain, DataMap map, Object where, Object content) {
+    public PasteUndoableEdit(DataChannelDescriptor domain, DataMap map, Object where, Object content) {
         this.domain = domain;
         this.map = map;
         this.where = where;
@@ -88,11 +88,11 @@
                 .getAction(RemoveProcedureParameterAction.getActionName());
 
         if (content instanceof DataMap) {
-            if (where instanceof DataDomain) {
-                rAction.removeDataMap((DataDomain) where, (DataMap) content);
+            if (where instanceof DataChannelDescriptor) {
+                rAction.removeDataMap((DataMap) content);
             }
-            else if (where instanceof DataNode) {
-                rAction.removeDataMapFromDataNode((DataNode) where, (DataMap) content);
+            else if (where instanceof DataNodeDescriptor) {
+                rAction.removeDataMapFromDataNode((DataNodeDescriptor) where, (DataMap) content);
             }
         }
         else if (where instanceof DataMap) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -21,7 +21,7 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -36,7 +36,7 @@
 
 public class RemoveAttributeUndoableEdit extends CayenneUndoableEdit {
 
-    private DataDomain domain;
+    private DataChannelDescriptor domain;
     private DataMap dataMap;
 
     private DbAttribute[] dbAttributes;
@@ -55,7 +55,7 @@
         this.embeddableAttrs = embeddableAttrs;
     }
 
-    public RemoveAttributeUndoableEdit(DataDomain domain, DataMap dataMap,
+    public RemoveAttributeUndoableEdit(DataChannelDescriptor domain, DataMap dataMap,
             ObjEntity entity, ObjAttribute[] attribs) {
         this.objEntity = entity;
         this.objAttributes = attribs;
@@ -63,7 +63,7 @@
         this.dataMap = dataMap;
     }
 
-    public RemoveAttributeUndoableEdit(DataDomain domain, DataMap dataMap,
+    public RemoveAttributeUndoableEdit(DataChannelDescriptor domain, DataMap dataMap,
             DbEntity entity, DbAttribute[] attribs) {
         this.dbEntity = entity;
         this.dbAttributes = attribs;
@@ -112,13 +112,13 @@
 
         if (objEntity != null) {
             for (ObjAttribute attr : objAttributes) {
-                action.createObjAttribute(domain, dataMap, objEntity, attr);
+                action.createObjAttribute(dataMap, objEntity, attr);
             }
         }
 
         if (dbEntity != null) {
             for (DbAttribute attr : dbAttributes) {
-                action.createDbAttribute(domain, dataMap, dbEntity, attr);
+                action.createDbAttribute(dataMap, dbEntity, attr);
             }
         }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java Tue Feb  2 13:06:56 2010
@@ -28,9 +28,9 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.configuration.event.DataNodeEvent;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
@@ -43,7 +43,6 @@
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.action.CreateDataMapAction;
 import org.apache.cayenne.modeler.action.CreateDbEntityAction;
-import org.apache.cayenne.modeler.action.CreateDomainAction;
 import org.apache.cayenne.modeler.action.CreateEmbeddableAction;
 import org.apache.cayenne.modeler.action.CreateNodeAction;
 import org.apache.cayenne.modeler.action.CreateObjEntityAction;
@@ -63,8 +62,8 @@
     private Query query;
     private Procedure procedure;
 
-    private DataNode dataNode;
-    private DataDomain domain;
+    private DataNodeDescriptor dataNode;
+    private DataChannelDescriptor domain;
 
     private Embeddable embeddable;
 
@@ -77,25 +76,25 @@
 
     private REMOVE_MODE mode;
 
-    public RemoveUndoableEdit(Application application, DataDomain domain) {
-        this.domain = domain;
+    public RemoveUndoableEdit(Application application) {
+        this.domain = (DataChannelDescriptor)application.getProject().getRootNode();;
         this.mode = REMOVE_MODE.DOMAIN;
     }
 
-    public RemoveUndoableEdit(Application application, DataNode node, DataMap map) {
+    public RemoveUndoableEdit(Application application, DataNodeDescriptor node, DataMap map) {
         this.map = map;
         this.dataNode = node;
         this.mode = REMOVE_MODE.MAP_FROM_NODE;
     }
 
-    public RemoveUndoableEdit(Application application, DataDomain domain, DataMap map) {
-        this.domain = domain;
+    public RemoveUndoableEdit(Application application, DataMap map) {
+        this.domain = (DataChannelDescriptor)application.getProject().getRootNode();;
         this.map = map;
         this.mode = REMOVE_MODE.MAP_FROM_DOMAIN;
     }
 
-    public RemoveUndoableEdit(Application application, DataDomain domain, DataNode node) {
-        this.domain = domain;
+    public RemoveUndoableEdit(Application application, DataNodeDescriptor node) {
+        this.domain = (DataChannelDescriptor)application.getProject().getRootNode();;
         this.dataNode = node;
         this.mode = REMOVE_MODE.NODE;
     }
@@ -216,13 +215,10 @@
                 action.removeDataMapFromDataNode(dataNode, map);
                 break;
             case MAP_FROM_DOMAIN:
-                action.removeDataMap(domain, map);
+                action.removeDataMap(map);
                 break;
             case NODE:
-                action.removeDataNode(domain, dataNode);
-                break;
-            case DOMAIN:
-                action.removeDomain(domain);
+                action.removeDataNode(dataNode);
                 break;
             case EMBEDDABLE:
                 action.removeEmbeddable(map, embeddable);
@@ -270,11 +266,12 @@
                 break;
             }
             case QUERY: {
-                this.domain = Application
+               
+                this.domain = (DataChannelDescriptor)Application
                         .getInstance()
                         .getFrameController()
                         .getProjectController()
-                        .findDomain(map);
+                        .getProject().getRootNode();
 
                 CreateQueryAction action = (CreateQueryAction) actionManager
                         .getAction(CreateQueryAction.getActionName());
@@ -290,7 +287,7 @@
                 break;
             }
             case MAP_FROM_NODE: {
-                this.dataNode.addDataMap(map);
+                this.dataNode.getDataMapNames().add(map.getName());
 
                 DataNodeEvent e = new DataNodeEvent(Application.getFrame(), this.dataNode);
 
@@ -299,7 +296,7 @@
                         .getFrameController()
                         .getProjectController();
 
-                e.setDomain(controller.findDomain(this.dataNode));
+                e.setDomain( (DataChannelDescriptor)controller.getProject().getRootNode());
 
                 controller.fireDataNodeEvent(e);
                 
@@ -308,22 +305,14 @@
             case MAP_FROM_DOMAIN: {
                 CreateDataMapAction action = (CreateDataMapAction) actionManager
                         .getAction(CreateDataMapAction.getActionName());
-                action.createDataMap(domain, map);
+                action.createDataMap(map);
                 
                 break;
             }
             case NODE: {
                 CreateNodeAction action = (CreateNodeAction) actionManager
                         .getAction(CreateNodeAction.getActionName());
-                action.createDataNode(domain, dataNode);
-                
-                break;
-            }
-
-            case DOMAIN: {
-                CreateDomainAction action = (CreateDomainAction) actionManager
-                        .getAction(CreateDomainAction.getActionName());
-                action.createDomain(domain);
+                action.createDataNode(dataNode);
                 
                 break;
             }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java Tue Feb  2 13:06:56 2010
@@ -29,8 +29,8 @@
 import javax.swing.undo.CannotUndoException;
 import javax.swing.undo.CompoundEdit;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.Embeddable;
@@ -101,7 +101,7 @@
             tabbedPane = editorView.getEjbqlQueryView();
         }
 
-        if (targetObject instanceof DataNode) {
+        if (targetObject instanceof DataNodeDescriptor) {
             tabbedPane = editorView.getDataNodeView();
         }
 
@@ -109,7 +109,7 @@
             tabbedPane = editorView.getDataMapView();
         }
 
-        if (targetObject instanceof DataDomain) {
+        if (targetObject instanceof DataChannelDescriptor) {
             tabbedPane = editorView.getDataDomainView();
         }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java Tue Feb  2 13:06:56 2010
@@ -33,8 +33,8 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ErrorDebugDialog;
-import org.apache.cayenne.project.Project;
 import org.apache.cayenne.project.ProjectPath;
+import org.apache.cayenne.project2.Project;
 import org.apache.cayenne.util.Util;
 
 /**

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java Tue Feb  2 13:06:56 2010
@@ -52,7 +52,7 @@
     private static Log logObj = LogFactory.getLog(CayenneController.class);
 
     protected CayenneController parent;
-    protected Application application;
+    protected static Application application;
     protected PropertyChangeSupport propertyChangeSupport;
 
     public CayenneController(CayenneController parent) {
@@ -64,7 +64,7 @@
         this.application = application;
     }
 
-    public Application getApplication() {
+    public static Application getApplication() {
         return application;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java Tue Feb  2 13:06:56 2010
@@ -33,8 +33,8 @@
 import javax.swing.tree.DefaultTreeCellRenderer;
 import javax.swing.tree.TreeCellRenderer;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
@@ -86,10 +86,10 @@
             return null;
         }
 
-        if (object instanceof DataDomain) {
+        if (object instanceof DataChannelDescriptor) {
             return domainIcon;
         }
-        else if (object instanceof DataNode) {
+        else if (object instanceof DataNodeDescriptor) {
             return nodeIcon;
         }
         else if (object instanceof DataMap) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java Tue Feb  2 13:06:56 2010
@@ -21,7 +21,7 @@
 
 import java.util.Comparator;
 
-import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
@@ -118,7 +118,7 @@
             if (o instanceof DataMap) {
                 return 1;
             }
-            else if (o instanceof DataNode) {
+            else if (o instanceof DataNodeDescriptor) {
                 return 2;
             }
             else {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/FileFilters.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/FileFilters.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/FileFilters.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/FileFilters.java Tue Feb  2 13:06:56 2010
@@ -20,10 +20,7 @@
 package org.apache.cayenne.modeler.util;
 
 import java.io.File;
-
 import javax.swing.filechooser.FileFilter;
-
-import org.apache.cayenne.conf.Configuration;
 import org.apache.cayenne.project.DataMapFile;
 
 /**
@@ -139,14 +136,14 @@
          */
         public boolean accept(File f) {
             return f.isDirectory()
-                || Configuration.DEFAULT_DOMAIN_FILE.equals(f.getName());
+                || (f.getName().startsWith("cayenne") && f.getName().endsWith(".xml"));
         }
 
         /**
          *  Returns description of this filter.
          */
         public String getDescription() {
-            return "Cayenne Applications (" + Configuration.DEFAULT_DOMAIN_FILE + ")";
+            return "Cayenne Applications (" + "cayenne*.xml" + ")";
         }
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java Tue Feb  2 13:06:56 2010
@@ -19,7 +19,6 @@
 
 package org.apache.cayenne.modeler.util;
 
-import java.io.File;
 import java.io.Serializable;
 import java.math.BigInteger;
 import java.net.URL;
@@ -33,18 +32,15 @@
 
 import javax.swing.ImageIcon;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.types.ExtendedTypeMap;
-import org.apache.cayenne.conf.Configuration;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ModelerConstants;
-import org.apache.cayenne.modeler.ModelerProject;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.action.MultipleObjectsAction;
-import org.apache.cayenne.project.ApplicationProject;
 import org.apache.cayenne.reflect.PropertyUtils;
 import org.apache.cayenne.util.CayenneMapEntry;
 
@@ -143,24 +139,15 @@
         return finalList;
     }
 
-    public static DataNode getNodeLinkedToMap(DataDomain domain, DataMap map) {
-        Collection<DataNode> nodes = domain.getDataNodes();
+    public static DataNodeDescriptor getNodeLinkedToMap(DataChannelDescriptor domain, DataMap map) {
+        Collection<DataNodeDescriptor> nodes = domain.getNodeDescriptors();
 
         // go via an iterator in an indexed loop, since
         // we already obtained the size
         // (and index is required to initialize array)
-        for (DataNode node : nodes)
-            if (node.getDataMaps().contains(map))
+        for (DataNodeDescriptor node : nodes)
+            if (node.getDataMapNames().contains(map.getName()))
                 return node;
-            
-//        Iterator nodesIt = nodes.iterator();
-//        while (nodesIt.hasNext()) {
-//            DataNode node = (DataNode) nodesIt.next();
-//
-//            if (node.getDataMaps().contains(map)) {
-//                return node;
-//            }
-//        }
 
         return null;
     }
@@ -179,12 +166,4 @@
             }
         }
     }
-    
-    /**
-     * Factory method to create modeler-specific project
-     */
-    public static ApplicationProject createModelerProject(File projectFile, Configuration configuration,
-            ProjectController mediator) {
-        return new ModelerProject(projectFile, configuration);
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java Tue Feb  2 13:06:56 2010
@@ -24,9 +24,8 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.conf.Configuration;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
@@ -71,7 +70,7 @@
         procedure.addCallParameter(parameter);
     }
 
-    public static void setDataMapName(DataDomain domain, DataMap map, String newName) {
+    public static void setDataMapName(DataChannelDescriptor domain, DataMap map, String newName) {
         String oldName = map.getName();
 
         // If name hasn't changed, just return
@@ -80,24 +79,23 @@
         }
 
         // must fully relink renamed map
-        List<DataNode> nodes = new ArrayList<DataNode>();
-        for (DataNode node : domain.getDataNodes())
-            if (node.getDataMaps().contains(map))
+        List<DataNodeDescriptor> nodes = new ArrayList<DataNodeDescriptor>();
+        for (DataNodeDescriptor node : domain.getNodeDescriptors())
+            if (node.getDataMapNames().contains(map.getName()))
                 nodes.add(node);
 
-        domain.removeMap(oldName);
+        domain.getDataMaps().remove(domain.getDataMap(oldName));
         map.setName(newName);
-        domain.addMap(map);
+        domain.getDataMaps().add(map);
 
-        for (DataNode node : nodes) {
-            node.removeDataMap(oldName);
-            node.addDataMap(map);
+        for (DataNodeDescriptor node : nodes) {
+            node.getDataMapNames().remove(oldName);
+            node.getDataMapNames().add(map.getName());
         }
     }
 
     public static void setDataDomainName(
-            Configuration configuration,
-            DataDomain domain,
+            DataChannelDescriptor domain,
             String newName) {
 
         String oldName = domain.getName();
@@ -107,15 +105,13 @@
         }
 
         domain.setName(newName);
-        configuration.removeDomain(oldName);
-        configuration.addDomain(domain);
     }
 
-    public static void setDataNodeName(DataDomain domain, DataNode node, String newName) {
+    public static void setDataNodeName(DataChannelDescriptor domain, DataNodeDescriptor node, String newName) {
         String oldName = node.getName();
         node.setName(newName);
-        domain.removeDataNode(oldName);
-        domain.addNode(node);
+        domain.getNodeDescriptors().remove(oldName);
+        domain.getNodeDescriptors().add(node);
     }
 
     public static void setProcedureName(DataMap map, Procedure procedure, String newName) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayennePreferenceService.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayennePreferenceService.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayennePreferenceService.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/CayennePreferenceService.java Tue Feb  2 13:06:56 2010
@@ -20,6 +20,7 @@
 package org.apache.cayenne.pref;
 
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -158,7 +159,18 @@
 
         for (DataMap dataMap : domain.getDataMaps()) {
             DataMap map = dataMap;
-            DataNode node = domain.lookupDataNode(map);
+            
+            DataNode node = null;
+                
+            Iterator<DataNode> it = domain.getDataNodes().iterator();
+            while(it.hasNext()){
+                DataNode descr = it.next();
+                if(descr.getDataMaps().contains(map)){
+                    node = descr;
+                    break;
+                }
+            }
+            
             DbAdapter adapter = node.getAdapter();
             DbGenerator generator = new DbGenerator(adapter, map);
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/configuration/event/DataNodeEventTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/configuration/event/DataNodeEventTest.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/configuration/event/DataNodeEventTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/configuration/event/DataNodeEventTest.java Tue Feb  2 13:06:56 2010
@@ -21,7 +21,7 @@
 
 import junit.framework.TestCase;
 
-import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.event.MapEvent;
 
 /**
@@ -29,12 +29,12 @@
 public class DataNodeEventTest extends TestCase {
 
     public void testNewName() throws Exception {
-        MapEvent event = new DataNodeEvent(new Object(), new DataNode("someName"));
+        MapEvent event = new DataNodeEvent(new Object(), new DataNodeDescriptor("someName"));
         assertEquals("someName", event.getNewName());
     }
 
     public void testNoNameChange() throws Exception {
-        MapEvent event = new DataNodeEvent(new Object(), new DataNode("someName"));
+        MapEvent event = new DataNodeEvent(new Object(), new DataNodeDescriptor("someName"));
         assertFalse(event.isNameChange());
         
         event.setOldName("someOldName");
@@ -44,7 +44,7 @@
     public void testNameChange() throws Exception {
         MapEvent event = new DataNodeEvent(
                 new Object(),
-                new DataNode("someName"),
+                new DataNodeDescriptor("someName"),
                 "someOldName");
         assertEquals("someName", event.getNewName());
         assertTrue(event.isNameChange());

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/CreateNodeActionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/CreateNodeActionTest.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/CreateNodeActionTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/CreateNodeActionTest.java Tue Feb  2 13:06:56 2010
@@ -19,14 +19,12 @@
 
 package org.apache.cayenne.modeler.action;
 
-import javax.sql.DataSource;
 
 import junit.framework.TestCase;
 
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
-
-import com.mockrunner.mock.jdbc.MockDataSource;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.conn.DataSourceInfo;
 
 public class CreateNodeActionTest extends TestCase {
 
@@ -42,15 +40,17 @@
             return;
         }
 
-        DataNode node = action.buildDataNode(new DataDomain("DD"));
+        DataChannelDescriptor domain = new DataChannelDescriptor();
+        domain.setName("aa");
+        DataNodeDescriptor node = action.buildDataNode(domain);
 
         assertNotNull(node);
         assertNotNull(node.getName());
 
-        DataSource ds1 = new MockDataSource();
-        node.setDataSource(ds1);
+        DataSourceInfo ds1 = new DataSourceInfo();
+        node.setDataSourceDescriptor(ds1);
 
         assertSame("Project DataNode must not wrap the DataSource", ds1, node
-                .getDataSource());
+                .getDataSourceDescriptor());
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainDisplayEventTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainDisplayEventTest.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainDisplayEventTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainDisplayEventTest.java Tue Feb  2 13:06:56 2010
@@ -21,14 +21,14 @@
 
 import junit.framework.TestCase;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 
 /**
  */
 public class DomainDisplayEventTest extends TestCase {
 
 	public void testDomain() throws Exception {
-		DataDomain d = new DataDomain("abc");
+		DataChannelDescriptor d = new DataChannelDescriptor();
 		DomainDisplayEvent e = new DomainDisplayEvent(new Object(), d);
 		assertSame(d, e.getDomain());
 	}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainEventTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainEventTest.java?rev=905616&r1=905615&r2=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainEventTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/event/DomainEventTest.java Tue Feb  2 13:06:56 2010
@@ -21,7 +21,7 @@
 
 import junit.framework.TestCase;
 
-import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.event.DomainEvent;
 
 /**
@@ -30,7 +30,7 @@
 
     public void testConstructor1() throws Exception {
     	Object src = new Object();
-    	DataDomain d = new DataDomain("abc");
+    	DataChannelDescriptor d = new DataChannelDescriptor();
     	DomainEvent e = new DomainEvent(src, d);
     	
     	assertSame(src, e.getSource());
@@ -39,7 +39,7 @@
     
     public void testConstructor2() throws Exception  {
     	Object src = new Object();
-    	DataDomain d = new DataDomain("abc");
+    	DataChannelDescriptor d = new DataChannelDescriptor();
     	DomainEvent e = new DomainEvent(src, d, "oldname");
     	
     	assertSame(src, e.getSource());
@@ -49,7 +49,7 @@
     
     public void testDomain() throws Exception  {
     	Object src = new Object();
-   	    DataDomain d = new DataDomain("abc");
+   	    DataChannelDescriptor d = new DataChannelDescriptor();
     	DomainEvent e = new DomainEvent(src, null);
     	
     	e.setDomain(d);

Added: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/ConfigurationValidationVisitor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/ConfigurationValidationVisitor.java?rev=905616&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/ConfigurationValidationVisitor.java (added)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/ConfigurationValidationVisitor.java Tue Feb  2 13:06:56 2010
@@ -0,0 +1,282 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.project2.validate;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
+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.project.ProjectPath;
+import org.apache.cayenne.project.validator.ValidationInfo;
+import org.apache.cayenne.project2.Project;
+import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.ProcedureQuery;
+import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+
+
+public class ConfigurationValidationVisitor implements ConfigurationNodeVisitor {
+
+    protected List<ValidationInfo> validationResults = new ArrayList<ValidationInfo>();
+    protected int maxSeverity;
+    protected Project project;
+    
+    /* Validators */
+    protected DataChannelValidator dataChannelValidator = new DataChannelValidator();
+    protected DataNodeValidator nodeValidator = new DataNodeValidator();
+    protected DataMapValidator mapValidator = new DataMapValidator();
+    protected ObjEntityValidator objEntityValidator = new ObjEntityValidator();
+    protected ObjAttributeValidator objAttrValidator = new ObjAttributeValidator();
+    protected ObjRelationshipValidator objRelValidator = new ObjRelationshipValidator();
+    protected DbEntityValidator dbEntityValidator = new DbEntityValidator();
+    protected DbAttributeValidator dbAttrValidator = new DbAttributeValidator();
+    protected DbRelationshipValidator dbRelValidator = new DbRelationshipValidator();
+    protected EmbeddableAttributeValidator embeddableAttributeValidator = new EmbeddableAttributeValidator();
+    protected EmbeddableValidator embeddableValidator = new EmbeddableValidator();
+    protected ProcedureValidator procedureValidator = new ProcedureValidator();
+    protected ProcedureParameterValidator procedureParameterValidator = new ProcedureParameterValidator();
+    protected SelectQueryValidator selectQueryValidator = new SelectQueryValidator();
+    protected ProcedureQueryValidator procedureQueryValidator = new ProcedureQueryValidator();
+    protected EJBQLQueryValidator ejbqlQueryValidator = new EJBQLQueryValidator();
+    protected SQLTemplateValidator sqlTemplateValidator = new SQLTemplateValidator();
+    
+    public ConfigurationValidationVisitor(Project project) {
+        this.project = project;
+    }
+    
+    public int getMaxSeverity() {
+        return maxSeverity;
+    }
+    
+    public Project getProject() {
+        return project;
+    }
+
+    public Object visitDataChannelDescriptor(DataChannelDescriptor channelDescriptor) {
+        dataChannelValidator.validate(channelDescriptor, this);
+        Iterator<DataNodeDescriptor> it = channelDescriptor.getNodeDescriptors().iterator();
+        if(it.hasNext()){
+            DataNodeDescriptor node = it.next();
+            visitDataNodeDescriptor(node);
+        }
+        
+        Iterator<DataMap> itMap = channelDescriptor.getDataMaps().iterator();
+        if(itMap.hasNext()){
+            DataMap map = itMap.next();
+            visitDataMap(map);
+        }
+        return validationResults;
+    }
+
+    public Object visitDataMap(DataMap dataMap) {
+        mapValidator.validate(dataMap, this);
+        Iterator<Embeddable> itEmb = dataMap.getEmbeddables().iterator();
+        while (itEmb.hasNext()) {
+            Embeddable emb = itEmb.next();
+            visitEmbeddable(emb);
+        }
+        
+        Iterator<ObjEntity> itObjEnt = dataMap.getObjEntities().iterator();
+        while (itObjEnt.hasNext()) {
+            ObjEntity ent = itObjEnt.next();
+            visitObjEntity(ent);
+        }
+        
+        Iterator<DbEntity> itDbEnt = dataMap.getDbEntities().iterator();
+        while (itDbEnt.hasNext()) {
+            DbEntity ent = itDbEnt.next();
+            visitDbEntity(ent);
+        }
+        
+        Iterator<Procedure> itProc = dataMap.getProcedures().iterator();
+        while (itProc.hasNext()) {
+            Procedure proc = itProc.next();
+            visitProcedure(proc);
+        }
+        
+        Iterator<Query> itQuer = dataMap.getQueries().iterator();
+        while (itQuer.hasNext()) {
+            Query q = itQuer.next();
+            visitQuery(q);
+        }
+        
+        return validationResults;
+    }
+
+    public Object visitDataNodeDescriptor(DataNodeDescriptor nodeDescriptor) {
+        nodeValidator.validate(nodeDescriptor, this);
+        return validationResults;
+    }
+
+    public Object visitDbAttribute(DbAttribute attribute) {
+        dbAttrValidator.validate(attribute, this);
+        return validationResults;
+    }
+
+    public Object visitDbEntity(DbEntity entity) {
+        dbEntityValidator.validate(entity, this);
+        
+        Iterator<DbAttribute> itAttr = entity.getAttributes().iterator();
+        while(itAttr.hasNext()){
+            DbAttribute attr = itAttr.next();
+            visitDbAttribute(attr);
+        }
+        
+        Iterator<DbRelationship> itRel = entity.getRelationships().iterator();
+        while(itRel.hasNext()){
+            DbRelationship rel = itRel.next();
+            visitDbRelationship(rel);
+        }
+        return validationResults;
+    }
+
+    public Object visitDbRelationship(DbRelationship relationship) {
+        return null;
+    }
+
+    public Object visitEmbeddable(Embeddable embeddable) {
+        embeddableValidator.validate(embeddable, this);
+        Iterator<EmbeddableAttribute> it = embeddable.getAttributes().iterator();
+        while(it.hasNext()){
+            EmbeddableAttribute attr = it.next();
+            visitEmbeddableAttribute(attr);
+        }
+        return validationResults;
+    }
+
+    public Object visitEmbeddableAttribute(EmbeddableAttribute attribute) {
+        embeddableAttributeValidator.validate(attribute, this);
+        return validationResults;
+    }
+
+    public Object visitObjAttribute(ObjAttribute attribute) {
+        objAttrValidator.validate(attribute, this);
+        return validationResults;
+    }
+
+    public Object visitObjEntity(ObjEntity entity) {
+        objEntityValidator.validate(entity, this);
+        
+        Iterator<ObjAttribute> itAttr = entity.getAttributes().iterator();
+        while(itAttr.hasNext()){
+            ObjAttribute attr = itAttr.next();
+            visitObjAttribute(attr);
+        }
+        
+        Iterator<ObjRelationship> itRel = entity.getRelationships().iterator();
+        while(itRel.hasNext()){
+            ObjRelationship rel = itRel.next();
+            visitObjRelationship(rel);
+        }
+        return validationResults;
+    }
+
+    public Object visitObjRelationship(ObjRelationship relationship) {
+        objRelValidator.validate(relationship, this);
+        return validationResults;
+    }
+
+    public Object visitProcedure(Procedure procedure) {
+        procedureValidator.validate(procedure, this);
+        ProcedureParameter parameter = procedure.getResultParam();
+        visitProcedureParameter(parameter);
+        Iterator<ProcedureParameter> itPrOut = procedure.getCallOutParameters().iterator();
+        while(itPrOut.hasNext()){
+            ProcedureParameter procPar = itPrOut.next();
+            visitProcedureParameter(procPar);
+        }
+        
+        Iterator<ProcedureParameter> itPr = procedure.getCallParameters().iterator();
+        while(itPr.hasNext()){
+            ProcedureParameter procPar = itPr.next();
+            visitProcedureParameter(procPar);
+        }
+        return validationResults;
+    }
+
+    public Object visitProcedureParameter(ProcedureParameter parameter) {
+        procedureParameterValidator.validate(parameter, this);
+        return validationResults;
+    }
+
+    public Object visitQuery(Query query) {
+        if (query instanceof SelectQuery) {
+            selectQueryValidator.validate(query, this);
+        }
+        else if (query instanceof SQLTemplate) {
+            sqlTemplateValidator.validate(query, this);
+        }
+        else if (query instanceof ProcedureQuery) {
+            procedureQueryValidator.validate(query, this);
+        }
+        else if (query instanceof EJBQLQuery) {
+            ejbqlQueryValidator.validate(query, this);
+        }
+        else {
+            // ignore unknown nodes
+            return null;
+        }
+        return validationResults;
+    }
+    
+    /**
+     * Registers validation result. 
+     * Increases internally stored max severity if 
+     * <code>result</code> parameter has a higher severity then the current value. 
+     * Leaves current value unchanged otherwise.
+     */
+    public void registerValidated(
+        int severity,
+        String message,
+        ProjectPath treeNodePath) {
+        ValidationInfo result = new ValidationInfo(severity, message, treeNodePath);
+        validationResults.add(result);
+        if (maxSeverity < severity) {
+            maxSeverity = severity;
+        }
+    }
+    
+    public void registerError(String message, ProjectPath treeNodePath) {
+        registerValidated(ValidationInfo.ERROR, message, treeNodePath);
+    }
+
+    public void registerWarning(String message, ProjectPath treeNodePath) {
+        registerValidated(ValidationInfo.WARNING, message, treeNodePath);
+    }
+    
+    /** Return collection of ValidationInfo objects from last validation. */
+    public List<ValidationInfo> validationResults() {
+        return validationResults;
+    }
+}

Copied: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataChannelValidator.java (from r905298, cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/ModelerProjectLoaderDelegateTest.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataChannelValidator.java?p2=cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataChannelValidator.java&p1=cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/ModelerProjectLoaderDelegateTest.java&r1=905298&r2=905616&rev=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/ModelerProjectLoaderDelegateTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataChannelValidator.java Tue Feb  2 13:06:56 2010
@@ -16,33 +16,26 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
+package org.apache.cayenne.project2.validate;
 
-package org.apache.cayenne.modeler.action;
-
-import javax.sql.DataSource;
-
-import junit.framework.TestCase;
-
-import org.apache.cayenne.access.DataNode;
-
-import com.mockrunner.mock.jdbc.MockDataSource;
-
-public class ModelerProjectLoaderDelegateTest extends TestCase {
-
-    public void testDataSource() {
-
-        ModelerProjectLoadDelegate loader = new ModelerProjectLoadDelegate(
-                new MockConfiguration());
-
-        DataNode node = loader.createDataNode("ABC");
-
-        assertNotNull(node);
-        assertEquals("ABC", node.getName());
-
-        DataSource ds1 = new MockDataSource();
-        node.setDataSource(ds1);
-
-        assertSame("Project DataNode must not wrap the DataSource", ds1, node
-                .getDataSource());
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.project.ProjectPath;
+import org.apache.cayenne.util.Util;
+
+
+public class DataChannelValidator  implements Validator{
+
+    public void validate(Object object, ConfigurationValidationVisitor configurationValidationVisitor) {
+        
+        // check for empty name
+        DataChannelDescriptor domain = (DataChannelDescriptor) object;
+        String name = domain.getName();
+        if (Util.isEmptyString(name)) {
+            Object[] path = new Object[]{domain}; 
+            configurationValidationVisitor.registerError("Unnamed DataDomain.", new ProjectPath(path));
+
+            // no more name assertions
+            return;
+        }
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataMapValidator.java (from r905298, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/validator/DataMapValidator.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataMapValidator.java?p2=cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataMapValidator.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/validator/DataMapValidator.java&r1=905298&r2=905616&rev=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/validator/DataMapValidator.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataMapValidator.java Tue Feb  2 13:06:56 2010
@@ -16,61 +16,47 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
+package org.apache.cayenne.project2.validate;
 
-package org.apache.cayenne.project.validator;
-
-import java.util.Iterator;
-
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.project.ProjectPath;
 import org.apache.cayenne.util.Util;
 
-/**
- * Validator for DataMaps.
- * 
- */
-public class DataMapValidator extends TreeNodeValidator {
-
-    /**
-     * Constructor for DataMapValidator.
-     */
-    public DataMapValidator() {
-        super();
-    }
+public class DataMapValidator implements Validator {
 
-    @Override
-    public void validateObject(ProjectPath path, Validator validator) {
-        DataMap map = (DataMap) path.getObject();
-        validateName(map, path, validator);
+    public void validate(Object object, ConfigurationValidationVisitor configurationValidationVisitor) {
+        DataMap map = (DataMap) object;
+        ProjectPath path = new ProjectPath(new Object[]{(DataChannelDescriptor)configurationValidationVisitor.getProject().getRootNode(), map});
+        validateName(map, path, configurationValidationVisitor);
 
         // check if data map is not attached to any nodes
-        validateNodeLinks(map, path, validator);
+        validateNodeLinks(map, path, configurationValidationVisitor);
     }
-
-    protected void validateNodeLinks(DataMap map, ProjectPath path, Validator validator) {
-        DataDomain domain = (DataDomain) path.getObjectParent();
+  
+    protected void validateNodeLinks(DataMap map, ProjectPath path, ConfigurationValidationVisitor validator) {
+        DataChannelDescriptor domain = (DataChannelDescriptor) validator.getProject().getRootNode();
         if (domain == null) {
             return;
         }
         
         boolean unlinked = true;
         int nodeCount = 0;
-        for (final DataNode node : domain.getDataNodes()) {
+        for (final DataNodeDescriptor node : domain.getNodeDescriptors()) {
             nodeCount++;
-            if (node.getDataMaps().contains(map)) {
+            if (node.getDataMapNames().contains(map.getName())) {
                 unlinked = false;
                 break;
             }
         }
         
         if(unlinked && nodeCount > 0) {
-        	 validator.registerWarning("DataMap is not linked to any DataNodes.", path);
+             validator.registerWarning("DataMap is not linked to any DataNodes.", path);
         }
     }
 
-    protected void validateName(DataMap map, ProjectPath path, Validator validator) {
+    protected void validateName(DataMap map, ProjectPath path, ConfigurationValidationVisitor validator) {
         String name = map.getName();
 
         if (Util.isEmptyString(name)) {
@@ -78,7 +64,7 @@
             return;
         }
 
-        DataDomain domain = (DataDomain) path.getObjectParent();
+        DataChannelDescriptor domain = (DataChannelDescriptor) validator.getProject().getRootNode();
         if (domain == null) {
             return;
         }
@@ -95,4 +81,5 @@
             }
         }
     }
+    
 }

Copied: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataNodeValidator.java (from r905298, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/validator/DataNodeValidator.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataNodeValidator.java?p2=cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataNodeValidator.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/validator/DataNodeValidator.java&r1=905298&r2=905616&rev=905616&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/validator/DataNodeValidator.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DataNodeValidator.java Tue Feb  2 13:06:56 2010
@@ -16,51 +16,40 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
+package org.apache.cayenne.project2.validate;
 
-package org.apache.cayenne.project.validator;
-
-import java.util.Iterator;
-
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.conf.DriverDataSourceFactory;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.project.ProjectPath;
 import org.apache.cayenne.util.Util;
 
-/**
- */
-public class DataNodeValidator extends TreeNodeValidator {
-
-    /**
-     * Constructor for DataNodeValidator.
-     */
-    public DataNodeValidator() {
-        super();
-    }
 
-    @Override
-    public void validateObject(ProjectPath path, Validator validator) {
-        DataNode node = (DataNode) path.getObject();
-        validateName(node, path, validator);
-        validateConnection(node, path, validator);
+public class DataNodeValidator implements Validator{
+
+    public void validate(Object object, ConfigurationValidationVisitor configurationValidationVisitor) {
+        DataNodeDescriptor node = (DataNodeDescriptor) object;
+        ProjectPath path = new ProjectPath(new Object[]{configurationValidationVisitor.getProject(), node});
+        validateName(node, path, configurationValidationVisitor);
+        validateConnection(node, path, configurationValidationVisitor);
     }
 
-    protected void validateConnection(DataNode node, ProjectPath path, Validator validator) {
-        String factory = node.getDataSourceFactory();
+    protected void validateConnection(DataNodeDescriptor node, ProjectPath path, ConfigurationValidationVisitor validator) {
+        String factory = node.getDataSourceFactoryType();
 
         // If direct factory, make sure the location is a valid file name.
         if (Util.isEmptyString(factory)) {
             validator.registerError("No DataSource factory.", path);
         }
-        else if (!DriverDataSourceFactory.class.getName().equals(factory)) {
-            String location = node.getDataSourceLocation();
+        else if(!DriverDataSourceFactory.class.getName().equals(factory)){
+            String location = node.getParameters();
             if (Util.isEmptyString(location)) {
                 validator.registerError("DataNode has no location parameter.", path);
             }
         }
     }
 
-    protected void validateName(DataNode node, ProjectPath path, Validator validator) {
+    protected void validateName(DataNodeDescriptor node, ProjectPath path, ConfigurationValidationVisitor validator) {
         String name = node.getName();
 
         if (Util.isEmptyString(name)) {
@@ -68,13 +57,9 @@
             return;
         }
 
-        DataDomain domain = (DataDomain) path.getObjectParent();
-        if (domain == null) {
-            return;
-        }
-
+        DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor)validator.getProject().getRootNode();
         // check for duplicate names in the parent context
-        for (final DataNode otherNode : domain.getDataNodes()) {
+        for (final DataNodeDescriptor otherNode : dataChannelDescriptor.getNodeDescriptors()) {
             if (otherNode == node) {
                 continue;
             }

Added: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DbAttributeValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DbAttributeValidator.java?rev=905616&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DbAttributeValidator.java (added)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validate/DbAttributeValidator.java Tue Feb  2 13:06:56 2010
@@ -0,0 +1,65 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.project2.validate;
+
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.dba.TypesMapping;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.project.ProjectPath;
+import org.apache.cayenne.project.validator.MappingNamesHelper;
+import org.apache.cayenne.util.Util;
+
+
+public class DbAttributeValidator  implements Validator{
+
+    public void validate(Object object, ConfigurationValidationVisitor validator) {
+        DbAttribute attribute = (DbAttribute) object;
+        
+        ProjectPath path = new ProjectPath(new Object[]{(DataChannelDescriptor)validator.getProject().getRootNode(), });
+        
+        // Must have name
+        if (Util.isEmptyString(attribute.getName())) {
+            validator.registerError("Unnamed DbAttribute.", path);
+        }
+        else {
+            MappingNamesHelper helper = MappingNamesHelper.getInstance();
+            String invalidChars = helper.invalidCharsInDbPathComponent(attribute
+                    .getName());
+            
+            if (invalidChars != null) {
+                validator.registerWarning("DbAttribute name contains invalid characters: "
+                        + invalidChars, path);
+            }
+        }
+
+        // all attributes must have type
+        if (attribute.getType() == TypesMapping.NOT_DEFINED) {
+            validator.registerWarning("DbAttribute has no type.", path);
+        }
+
+        // VARCHAR and CHAR attributes must have max length
+        else if (attribute.getMaxLength() < 0
+                && (attribute.getType() == java.sql.Types.VARCHAR || attribute.getType() == java.sql.Types.CHAR)) {
+
+            validator.registerWarning(
+                    "Character DbAttribute doesn't have max length.",
+                    path);
+        }
+    }
+}



Mime
View raw message