You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2002/12/24 14:49:22 UTC
cvs commit: jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel OjbMetaClassDescriptorNode.java OjbMetaRootNode.java ReverseDbNodesToOjbMetaDropWorker.java
arminw 2002/12/24 05:49:22
Modified: src/java/org/apache/ojb/tools/mapping/reversedb2/actions
ActionNewOJBRepository.java
ActionOpenOJBRepository.java
src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel
OjbMetaClassDescriptorNode.java
OjbMetaRootNode.java
ReverseDbNodesToOjbMetaDropWorker.java
Log:
NOTE: these classes should be updated
to handle correctly with the new
metadata implementation
Revision Changes Path
1.3 +3 -5 jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/actions/ActionNewOJBRepository.java
Index: ActionNewOJBRepository.java
===================================================================
RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/actions/ActionNewOJBRepository.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ActionNewOJBRepository.java 8 Nov 2002 13:29:29 -0000 1.2
+++ ActionNewOJBRepository.java 24 Dec 2002 13:49:22 -0000 1.3
@@ -67,13 +67,13 @@
{
private javax.swing.JFrame containingFrame;
/** Creates a new instance of ActionOpenOJBRepository */
- public ActionNewOJBRepository(javax.swing.JFrame pcontainingFrame)
+ public ActionNewOJBRepository(javax.swing.JFrame pcontainingFrame)
{
this.containingFrame = pcontainingFrame;
putValue(NAME, "New OJB Repository");
putValue(MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_N));
}
-
+
public void actionPerformed (java.awt.event.ActionEvent actionEvent)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
@@ -84,8 +84,6 @@
{
// RepositoryPersistor persistor = new RepositoryPersistor ();
DescriptorRepository repository = new DescriptorRepository();
- repository.setDefaultJdbcConnection(new JdbcConnectionDescriptor());
- repository.getDefaultJdbcConnection().setDbAlias("<UNKNOWN>");
JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
containingFrame.getContentPane().add(frm);
frm.setVisible(true);
@@ -95,6 +93,6 @@
t.printStackTrace();
}
}
- });
+ });
}
}
1.3 +4 -4 jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/actions/ActionOpenOJBRepository.java
Index: ActionOpenOJBRepository.java
===================================================================
RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/actions/ActionOpenOJBRepository.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ActionOpenOJBRepository.java 8 Nov 2002 13:47:38 -0000 1.2
+++ ActionOpenOJBRepository.java 24 Dec 2002 13:49:22 -0000 1.3
@@ -70,13 +70,13 @@
{
private javax.swing.JFrame containingFrame;
/** Creates a new instance of ActionOpenOJBRepository */
- public ActionOpenOJBRepository(javax.swing.JFrame pcontainingFrame)
+ public ActionOpenOJBRepository(javax.swing.JFrame pcontainingFrame)
{
this.containingFrame = pcontainingFrame;
putValue(NAME, "Open OJB Repository");
putValue(MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_O));
}
-
+
public void actionPerformed (java.awt.event.ActionEvent actionEvent)
{
String lastPath = Main.getProperties().getProperty("lastFileChooserPosition");
@@ -93,7 +93,7 @@
try
{
RepositoryPersistor persistor = new RepositoryPersistor ();
- DescriptorRepository repository = persistor.readFromFile(selectedFile.getCanonicalPath());
+ DescriptorRepository repository = persistor.readDescriptorRepository(selectedFile.getCanonicalPath());
JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
containingFrame.getContentPane().add(frm);
frm.setVisible(true);
@@ -103,7 +103,7 @@
t.printStackTrace();
}
}
- });
+ });
}
}
}
1.4 +49 -49 jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/OjbMetaClassDescriptorNode.java
Index: OjbMetaClassDescriptorNode.java
===================================================================
RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/OjbMetaClassDescriptorNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OjbMetaClassDescriptorNode.java 4 Sep 2002 16:15:33 -0000 1.3
+++ OjbMetaClassDescriptorNode.java 24 Dec 2002 13:49:22 -0000 1.4
@@ -23,11 +23,11 @@
{
private static java.util.ArrayList supportedActions = new java.util.ArrayList();
-
-
+
+
private ClassDescriptor cld;
/** Creates a new instance of OjbMetaClassDescriptorNode */
- public OjbMetaClassDescriptorNode (DescriptorRepository pRepository,
+ public OjbMetaClassDescriptorNode (DescriptorRepository pRepository,
OjbMetaDataTreeModel pTreeModel,
OjbMetaRootNode pparent,
ClassDescriptor pCld)
@@ -35,32 +35,32 @@
super(pRepository, pTreeModel, pparent);
this.cld = pCld;
}
-
+
public boolean getAllowsChildren ()
{
return true;
}
-
+
public Object getAttribute (String key)
{
return null;
}
-
+
public Class getPropertyEditorClass ()
{
return null;
}
-
+
public boolean isLeaf ()
{
return false;
}
-
+
public void setAttribute (String key, Object value)
{
-
+
}
-
+
/** Purpose of this method is to fill the children of the node. It should
* replace all children in alChildren (the arraylist containing the children)
* of this node and notify the TreeModel that a change has occurred.
@@ -68,17 +68,17 @@
protected boolean _load ()
{
java.util.ArrayList newChildren = new java.util.ArrayList();
-
-
- if (cld.getConnectionDescriptor() != null)
- {
- newChildren.add(new OjbMetaJdbcConnectionDescriptorNode(
- this.getOjbMetaTreeModel().getRepository(),
- this.getOjbMetaTreeModel(),
- this,
- cld.getConnectionDescriptor()));
- }
-
+
+ /* @todo make this work */
+// if (cld.getConnectionDescriptor() != null)
+// {
+// newChildren.add(new OjbMetaJdbcConnectionDescriptorNode(
+// this.getOjbMetaTreeModel().getRepository(),
+// this.getOjbMetaTreeModel(),
+// this,
+// cld.getConnectionDescriptor()));
+// }
+//
// Add collection descriptors
java.util.Iterator it = cld.getCollectionDescriptors().iterator();
while (it.hasNext())
@@ -89,11 +89,11 @@
this.getOjbMetaTreeModel(),
this,
collDesc));
-
+
}
-
+
// Add extent classes Class
-
+
it = cld.getExtentClassNames().iterator();
while (it.hasNext())
{
@@ -103,7 +103,7 @@
this.getOjbMetaTreeModel(),
this,
extentClassName));
-
+
}
// Get Field descriptors FieldDescriptor
@@ -126,7 +126,7 @@
}
// Get Indices IndexDescriptor
- it = cld.getIndexes().iterator();
+ it = cld.getIndexes().iterator();
while (it.hasNext())
{
IndexDescriptor indexDesc = (IndexDescriptor)it.next();
@@ -135,9 +135,9 @@
this.getOjbMetaTreeModel(),
this,
indexDesc));
-
+
}
-
+
// Get references ObjectReferenceDescriptor
it = cld.getObjectReferenceDescriptors().iterator();
while (it.hasNext())
@@ -148,41 +148,41 @@
this.getOjbMetaTreeModel(),
this,
objRefDesc));
-
- }
- // Add
+
+ }
+ // Add
this.alChildren = newChildren;
this.getOjbMetaTreeModel().nodeStructureChanged(this);
return true;
}
-
+
public String toString()
{
return "ClassDescriptor:" + this.cld.getClassNameOfObject();
// return "ClassDescriptor:" + this.cld.getClassOfObject().getName();
}
-
+
/**
* @see ActionTarget#getActions()
- */
- public java.util.Iterator getActions()
+ */
+ public java.util.Iterator getActions()
{
return supportedActions.iterator();
- }
-
+ }
+
/**
* @see ActionTarget#actionListCacheable()
- */
+ */
public boolean actionListCachable()
{
return true;
}
-
+
public boolean actionListStatic()
{
return true;
}
-
+
/** Adds <code>child</code> to the receiver at <code>index</code>.
* <code>child</code> will be messaged with <code>setParent</code>.
*
@@ -190,7 +190,7 @@
public void insert(javax.swing.tree.MutableTreeNode child, int index)
{
}
-
+
/** Removes <code>node</code> from the receiver. <code>setParent</code>
* will be messaged on <code>node</code>.
*
@@ -198,43 +198,43 @@
public void remove(javax.swing.tree.MutableTreeNode node)
{
}
-
+
/** Removes the child at <code>index</code> from the receiver.
*
*/
public void remove(int index)
{
}
-
+
/** Removes the receiver from its parent.
*
*/
public void removeFromParent()
{
}
-
+
/** Sets the parent of the receiver to <code>newParent</code>.
*
*/
public void setParent(javax.swing.tree.MutableTreeNode newParent)
{
}
-
+
/** Resets the user object of the receiver to <code>object</code>.
*
*/
public void setUserObject(Object object)
{
}
-
+
/**
- * Return the descriptor object this node is associated with. E.g. if the
+ * Return the descriptor object this node is associated with. E.g. if the
* node displays a class descriptor, the ClassDescriptor describing the class
* should be returned. Used for creating a Transferable.
- */
+ */
public Object getAssociatedDescriptor()
{
return cld;
}
-
+
}
1.4 +40 -37 jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/OjbMetaRootNode.java
Index: OjbMetaRootNode.java
===================================================================
RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/OjbMetaRootNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OjbMetaRootNode.java 4 Sep 2002 16:16:56 -0000 1.3
+++ OjbMetaRootNode.java 24 Dec 2002 13:49:22 -0000 1.4
@@ -3,10 +3,10 @@
/*
* ====================================================================
- *
+ *
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -22,15 +22,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
@@ -56,96 +56,99 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
/**
* This represents the root of the repository.xml tree model. It contains
* the ClassDescriptor objects for this repository and the default JDBC
* connection.
*
- * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
+ * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
* @version $Id$
*/
-public class OjbMetaRootNode extends OjbMetaTreeNode
+public class OjbMetaRootNode extends OjbMetaTreeNode
{
private java.util.ArrayList supportedActions = new java.util.ArrayList();
-
+
java.util.HashMap cldToNodes = new java.util.HashMap();
-
+
/** Creates a new instance of OjbMetaRootNode */
public OjbMetaRootNode(org.apache.ojb.broker.metadata.DescriptorRepository pRepository, OjbMetaDataTreeModel model)
{
super(pRepository, model, null);
supportedActions.add(new org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel.actions.ActionAddClassDescriptor(this));
}
-
+
public boolean getAllowsChildren ()
{
return true;
}
-
+
public Class getPropertyEditorClass ()
{
return null;
}
-
+
public boolean isLeaf ()
{
return false;
}
-
+
/** Get an attribute of this node as Object.
*/
public Object getAttribute (String strKey)
{
return null;
}
-
+
/** Set an attribute of this node as Object.
*/
public void setAttribute (String strKey, Object value)
{
}
-
+
public OjbMetaClassDescriptorNode getClassDescriptorNodeForClassDescriptor(org.apache.ojb.broker.metadata.ClassDescriptor cld)
{
return (OjbMetaClassDescriptorNode)this.cldToNodes.get(cld);
}
-
+
/** Purpose of this method is to fill the children of the node. It should
* replace all children in alChildren (the arraylist containing the children)
* of this node and notify the TreeModel that a change has occurred.
*/
protected boolean _load ()
{
- java.util.Iterator it =
+ java.util.Iterator it =
this.getOjbMetaTreeModel ().getRepository().iterator();
java.util.ArrayList newChildren = new java.util.ArrayList();
- newChildren.add(new OjbMetaJdbcConnectionDescriptorNode(
- this.getOjbMetaTreeModel ().getRepository(),
- this.getOjbMetaTreeModel (),
- this,
- this.getOjbMetaTreeModel ().getRepository().getDefaultJdbcConnection()));
-
+
+ /* @todo make this work */
+
+// newChildren.add(new OjbMetaJdbcConnectionDescriptorNode(
+// this.getOjbMetaTreeModel ().getRepository(),
+// this.getOjbMetaTreeModel (),
+// this,
+// this.getOjbMetaTreeModel ().getRepository().getDefaultJdbcConnection()));
+
while (it.hasNext())
{
org.apache.ojb.broker.metadata.ClassDescriptor cld = (org.apache.ojb.broker.metadata.ClassDescriptor)it.next();
- OjbMetaClassDescriptorNode cldNode =
+ OjbMetaClassDescriptorNode cldNode =
new OjbMetaClassDescriptorNode(this.getOjbMetaTreeModel ().getRepository(),
this.getOjbMetaTreeModel (),
this, cld);
cldToNodes.put(cld, cldNode);
newChildren.add(cldNode);
}
- java.util.Collections.sort(newChildren);
+ java.util.Collections.sort(newChildren);
this.alChildren = newChildren;
this.getOjbMetaTreeModel ().nodeStructureChanged(this);
return true;
}
-
+
public void addClassDescriptor(org.apache.ojb.broker.metadata.ClassDescriptor cld)
{
- OjbMetaClassDescriptorNode cldNode =
+ OjbMetaClassDescriptorNode cldNode =
new OjbMetaClassDescriptorNode(this.getOjbMetaTreeModel ().getRepository(),
this.getOjbMetaTreeModel (),
this, cld);
@@ -157,10 +160,10 @@
/**
* @see ActionTarget#getActions()
*/
- public java.util.Iterator getActions()
+ public java.util.Iterator getActions()
{
return supportedActions.iterator();
- }
+ }
/**
* @see ActionTarget#actionListCacheable()
@@ -169,7 +172,7 @@
{
return true;
}
-
+
/**
* @see ActionTarget
*/
@@ -177,16 +180,16 @@
{
return false;
}
-
+
/**
- * Return the descriptor object this node is associated with. E.g. if the
+ * Return the descriptor object this node is associated with. E.g. if the
* node displays a class descriptor, the ClassDescriptor describing the class
* should be returned. Used for creating a Transferable. Null in this case
* because the root doesn't have any associated objects.
- */
+ */
public Object getAssociatedDescriptor()
{
return null;
}
-
+
}
1.2 +30 -22 jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/ReverseDbNodesToOjbMetaDropWorker.java
Index: ReverseDbNodesToOjbMetaDropWorker.java
===================================================================
RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb2/ojbmetatreemodel/ReverseDbNodesToOjbMetaDropWorker.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReverseDbNodesToOjbMetaDropWorker.java 4 Sep 2002 16:13:55 -0000 1.1
+++ ReverseDbNodesToOjbMetaDropWorker.java 24 Dec 2002 13:49:22 -0000 1.2
@@ -8,12 +8,13 @@
import org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.*;
import org.apache.ojb.tools.mapping.reversedb2.datatransfer.*;
import org.apache.ojb.tools.mapping.reversedb2.dnd2.*;
+import org.apache.ojb.broker.util.ClassHelper;
/*
* ====================================================================
- *
+ *
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +22,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -29,15 +30,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
@@ -63,10 +64,10 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
/**
- * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
+ * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
* @version $Id$
*/
public class ReverseDbNodesToOjbMetaDropWorker implements DropPasteWorkerInterface
@@ -75,12 +76,12 @@
public ReverseDbNodesToOjbMetaDropWorker()
{
}
-
+
public int getAcceptableActions (java.awt.Component c)
{
return DnDWorkerConstants.DRAG_MOVE | DnDWorkerConstants.DRAG_COPY ;
}
-
+
public int getAcceptableActions (java.awt.Component c, java.awt.datatransfer.DataFlavor[] flavor)
{
for (int j = 0; j < flavor.length; j++)
@@ -91,26 +92,26 @@
}
return DnDWorkerConstants.NONE;
}
-
+
public java.awt.datatransfer.DataFlavor getSupportedDataFlavor ()
{
return TransferableDBMetaTreeNodes.DBMETATABLENODE_FLAVOR_REMOTE;
}
-
+
private java.util.Enumeration getTableNodes(java.util.Enumeration nodes)
{
- java.util.Vector tableVector = new java.util.Vector();
+ java.util.Vector tableVector = new java.util.Vector();
while(nodes.hasMoreElements())
{
ReverseDbTreeNode aNode = (ReverseDbTreeNode)nodes.nextElement();
- if (aNode instanceof DBMetaRootNode
- // || aNode instanceof DBMetaSchemaNode
+ if (aNode instanceof DBMetaRootNode
+ // || aNode instanceof DBMetaSchemaNode
|| aNode instanceof DBMetaCatalogNode)
{
java.util.Enumeration e = getTableNodes(aNode.children());
while (e.hasMoreElements()) tableVector.add(e.nextElement());
}
- else if (aNode instanceof DBMetaSchemaNode)
+ else if (aNode instanceof DBMetaSchemaNode)
{
java.util.Enumeration e = aNode.children();
while (e.hasMoreElements()) tableVector.add(e.nextElement());
@@ -121,13 +122,13 @@
}
}
return tableVector.elements();
-
+
}
-
+
public boolean importData (java.awt.Component c, java.awt.datatransfer.Transferable t, int action)
{
if (t.isDataFlavorSupported(TransferableDBMetaTreeNodes.DBMETATABLENODE_FLAVOR_REMOTE) &&
- c instanceof javax.swing.JTree &&
+ c instanceof javax.swing.JTree &&
((javax.swing.JTree)c).getModel() instanceof OjbMetaDataTreeModel)
{
OjbMetaDataTreeModel treeModel = (OjbMetaDataTreeModel)((javax.swing.JTree)c).getModel();
@@ -155,10 +156,17 @@
{
DBMetaTableNode dbTable = (DBMetaTableNode)o;
System.err.println("Adding " + dbTable);
- org.apache.ojb.broker.metadata.ClassDescriptor cld =
+ org.apache.ojb.broker.metadata.ClassDescriptor cld =
new org.apache.ojb.broker.metadata.ClassDescriptor(treeModel.getRepository());
cld.setTableName(dbTable.getTableName());
- cld.setClassNameOfObject(dbTable.getTableName());
+ try
+ {
+ cld.setClassOfObject(ClassHelper.getClass(dbTable.getTableName()));
+ }
+ catch (ClassNotFoundException e1)
+ {
+ e1.printStackTrace();
+ }
treeModel.getRepository().put(cld.getClassNameOfObject(), cld);
rootNode.addClassDescriptor(cld);
}