db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/src/schema ojbtest-data-new.xml
Date Mon, 26 Jul 2004 22:25:17 GMT
tomdz       2004/07/26 15:25:16

  Modified:    src/java/org/apache/ojb/broker/util/dbhandling
                        CommonsSqlDataHandling.java PreparedModel.java
                        CommonsSqlDatabaseHandling.java
                        DatabaseHandlingTask.java
               .        build.xml
               src/schema ojbtest-data-new.xml
  Log:
  DB creation and data dtd creation/data insertion is now working
  Created adapted data file version for unit tests
  
  Revision  Changes    Path
  1.2       +71 -39    db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDataHandling.java
  
  Index: CommonsSqlDataHandling.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDataHandling.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommonsSqlDataHandling.java	22 Jul 2004 07:48:52 -0000	1.1
  +++ CommonsSqlDataHandling.java	26 Jul 2004 22:25:15 -0000	1.2
  @@ -20,9 +20,12 @@
   import java.io.StringReader;
   import java.io.StringWriter;
   import java.io.Writer;
  +import java.sql.SQLException;
   import java.util.ArrayList;
   import java.util.Iterator;
   
  +import javax.sql.DataSource;
  +
   import org.apache.commons.beanutils.DynaBean;
   import org.apache.commons.digester.Digester;
   import org.apache.commons.digester.ExtendedBaseRules;
  @@ -32,7 +35,7 @@
   import org.apache.commons.sql.model.Column;
   import org.apache.commons.sql.model.Database;
   import org.apache.commons.sql.model.Table;
  -import org.apache.commons.sql.util.DDLExecutor;
  +import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.xml.sax.Attributes;
   import org.xml.sax.EntityResolver;
  @@ -70,6 +73,17 @@
                   }
               }
           }
  +
  +        public void insert(DataSource ds, Database db) throws SQLException
  +        {
  +            DynaSql      dynaSql = new DynaSql(ds, db);
  +            StringBuffer result  = new StringBuffer();
  +
  +            for (Iterator it = _beans.iterator(); it.hasNext();)
  +            {
  +                dynaSql.insert((DynaBean)it.next());
  +            }
  +        }
       }
   
       private class DynaFactoryCreateRule extends Rule
  @@ -91,7 +105,7 @@
   
               if (table == null)
               {
  -                throw new DatabaseHandlingException("The element "+name+" does not map
to a table in the database schema");
  +                throw new DatabaseHandlingException("Unknown element "+name);
               }
   
               DynaBean bean = _dynaSql.newInstance(table.getName());
  @@ -104,7 +118,7 @@
   
                   if (column == null)
                   {
  -                    throw new DatabaseHandlingException("The attribute "+attrName+" of
element "+name+" does not map to a column in table "+table.getName()+" in the database schema");
  +                    throw new DatabaseHandlingException("Unknown attribute "+attrName+"
of element "+name);
                   }
                   bean.set(column.getName(), attrValue);
               }
  @@ -171,37 +185,6 @@
       }
   
       /**
  -     * Returns the sql necessary to add the data XML contained in the given input stream.

  -     * Note that the data is expected to match the repository metadata (not the table schema).
  -     * Also note that you should not use the reader after passing it to this method except
closing
  -     * it (which is not done automatically).
  -     * 
  -     * @param input  A reader returning the content of the data file
  -     * @param output The writer to write the sql to
  -     */
  -    public void getInsertDataSql(Reader input, Writer output) throws DatabaseHandlingException
  -    {
  -        try
  -        {
  -            DataSet set = (DataSet)_digester.parse(input);
  -
  -            set.createInsertionSql(_db, output);
  -        }
  -        catch (Exception ex)
  -        {
  -            if (ex instanceof DatabaseHandlingException)
  -            {
  -                // is not declared by digester, but may be thrown
  -                throw (DatabaseHandlingException)ex;
  -            }
  -            else
  -            {
  -                throw new DatabaseHandlingException(ex);
  -            }
  -        }
  -    }
  -
  -    /**
        * Writes a DTD that can be used for data XML files matching the current model to the
given writer. 
        * 
        * @param output The writer to write the DTD to
  @@ -223,9 +206,28 @@
               output.write(")>\n<!ATTLIST dataset\n    name CDATA #REQUIRED\n>\n");
               for (Iterator it = _preparedModel.getElementNames(); it.hasNext();)
               {
  -                String elementName = (String)it.next();
  +                String    elementName = (String)it.next();
  +                ArrayList classDescs  = _preparedModel.getClassDescriptorsMappingTo(elementName);
   
  -                output.write("\n<!ELEMENT ");
  +                if (classDescs == null)
  +                {
  +                    output.write("\n<!-- Indirection table");
  +                }
  +                else
  +                {
  +                    output.write("\n<!-- Mapped to : ");
  +                    for (Iterator classDescIt = classDescs.iterator(); classDescIt.hasNext();)
  +                    {
  +                        ClassDescriptor classDesc = (ClassDescriptor)classDescIt.next();
  +    
  +                        output.write(classDesc.getClassNameOfObject());
  +                        if (classDescIt.hasNext())
  +                        {
  +                            output.write("\n                 ");
  +                        }
  +                    }
  +                }
  +                output.write(" -->\n<!ELEMENT ");
                   output.write(elementName);
                   output.write(" EMPTY>\n<!ATTLIST ");
                   output.write(elementName);
  @@ -259,15 +261,45 @@
        * @param input  A reader returning the content of the data file
        * @param output The writer to write the sql to
        */
  -    public void insertData(Reader input, DDLExecutor executor) throws DatabaseHandlingException
  +    public void getInsertDataSql(Reader input, Writer output) throws DatabaseHandlingException
  +    {
  +        try
  +        {
  +            DataSet set = (DataSet)_digester.parse(input);
  +
  +            set.createInsertionSql(_db, output);
  +        }
  +        catch (Exception ex)
  +        {
  +            if (ex instanceof DatabaseHandlingException)
  +            {
  +                // is not declared by digester, but may be thrown
  +                throw (DatabaseHandlingException)ex;
  +            }
  +            else
  +            {
  +                throw new DatabaseHandlingException(ex);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Returns the sql necessary to add the data XML contained in the given input stream.

  +     * Note that the data is expected to match the repository metadata (not the table schema).
  +     * Also note that you should not use the reader after passing it to this method except
closing
  +     * it (which is not done automatically).
  +     * 
  +     * @param input A reader returning the content of the data file
  +     * @param ds    The datasource
  +     */
  +    public void insertData(Reader input, DataSource ds) throws DatabaseHandlingException
       {
           try
           {
               DataSet      set    = (DataSet)_digester.parse(input);
               StringWriter writer = new StringWriter();
   
  -            set.createInsertionSql(_db, writer);
  -            executor.evaluateBatch(writer.getBuffer().toString());
  +            set.insert(ds, _db);
           }
           catch (Exception ex)
           {
  
  
  
  1.3       +88 -30    db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/PreparedModel.java
  
  Index: PreparedModel.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/PreparedModel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PreparedModel.java	23 Jul 2004 07:31:56 -0000	1.2
  +++ PreparedModel.java	26 Jul 2004 22:25:15 -0000	1.3
  @@ -24,6 +24,8 @@
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
  +import org.apache.ojb.broker.util.logging.Logger;
  +import org.apache.ojb.broker.util.logging.LoggerFactory;
   
   /**
    * Provides a model derived from {@link org.apache.ojb.broker.metadata.DescriptorRepository}
that
  @@ -33,9 +35,17 @@
    */
   public class PreparedModel
   {
  -    private TreeMap _elementToTable                = new TreeMap();
  -    private HashMap _elementToColumnMap            = new HashMap();
  -    private HashMap _elementToRequiredColumnsMap   = new HashMap();
  +    /** The log */
  +    private Logger  _log                            = LoggerFactory.getLogger(DatabaseHandling.class);
  +    /** Maps dtd elements to tables */
  +    private TreeMap _elementToTable                 = new TreeMap();
  +    /** Maps dtd elements to lists of class descriptors (which all map to the same table)
*/
  +    private HashMap _elementToClassDescriptors      = new HashMap();
  +    /** Maps dtd elements to colum maps which in turn map attribute names to columns */
  +    private HashMap _elementToColumnMap             = new HashMap();
  +    /** Maps dtd elements to maps that specify which attributes are required */
  +    private HashMap _elementToRequiredAttributesMap = new HashMap();
  +
       public PreparedModel(DescriptorRepository model, Database schema)
       {
           prepareModel(model, schema);
  @@ -55,25 +65,30 @@
   
       public boolean isRequired(String elementName, String attributeName)
       {
  -        HashMap requiredColumns = (HashMap)_elementToRequiredColumnsMap.get(elementName);
  +        HashMap requiredAttributes = (HashMap)_elementToRequiredAttributesMap.get(elementName);
   
  -        if (requiredColumns == null)
  +        if (requiredAttributes == null)
           {
               return false;
           }
           else
           {
  -            Boolean status = (Boolean)requiredColumns.get(attributeName);
  +            Boolean status = (Boolean)requiredAttributes.get(attributeName);
   
               return status == null ? false : status.booleanValue();
           }
       }
  -    
  +
       public Table getTableFor(String elementName)
       {
           return (Table)_elementToTable.get(elementName);
       }
   
  +    public ArrayList getClassDescriptorsMappingTo(String elementName)
  +    {
  +        return (ArrayList)_elementToClassDescriptors.get(elementName);
  +    }
  +
       public Column getColumnFor(String elementName, String attrName)
       {
           TreeMap columns = (TreeMap)_elementToColumnMap.get(elementName);
  @@ -94,11 +109,19 @@
   
           for (Iterator it = model.getDescriptorTable().values().iterator(); it.hasNext();)
           {
  -            ClassDescriptor classDesc          = (ClassDescriptor)it.next();
  -            String          elementName        = getElementName(classDesc.getClassNameOfObject());
  -            Table           mappedTable        = (Table)_elementToTable.get(elementName);
  -            TreeMap         columnsMap         = (TreeMap)_elementToColumnMap.get(elementName);
  -            HashMap         requiredColumnsMap = (HashMap)_elementToRequiredColumnsMap.get(elementName);
  +            ClassDescriptor classDesc = (ClassDescriptor)it.next();
  +
  +            if (classDesc.getFullTableName() == null)
  +            {
  +                // not mapped to a database table
  +                continue;
  +            }
  +
  +            String    elementName        = getElementName(classDesc);
  +            Table     mappedTable        = (Table)_elementToTable.get(elementName);
  +            TreeMap   columnsMap         = (TreeMap)_elementToColumnMap.get(elementName);
  +            HashMap   requiredAttributes = (HashMap)_elementToRequiredAttributesMap.get(elementName);
  +            ArrayList classDescs         = (ArrayList)_elementToClassDescriptors.get(elementName);
   
               if (mappedTable == null)
               {
  @@ -108,12 +131,15 @@
                       continue;
                   }
                   columnsMap         = new TreeMap();
  -                requiredColumnsMap = new HashMap();
  +                requiredAttributes = new HashMap();
  +                classDescs         = new ArrayList();
                   _elementToTable.put(elementName, mappedTable);
  +                _elementToClassDescriptors.put(elementName, classDescs);
                   _elementToColumnMap.put(elementName, columnsMap);
  -                _elementToRequiredColumnsMap.put(elementName, requiredColumnsMap);
  +                _elementToRequiredAttributesMap.put(elementName, requiredAttributes);
               }
  -            extractAttributes(classDesc, mappedTable, columnsMap, requiredColumnsMap);
  +            classDescs.add(classDesc);
  +            extractAttributes(classDesc, mappedTable, columnsMap, requiredAttributes);
           }
           extractIndirectionTables(model, schema);
       }
  @@ -130,11 +156,27 @@
   
                   if (column != null)
                   {
  -                    String shortAttrName = getShortAttributeName(fieldDescs[idx].getAttributeName());
  -    
  -                    columnsMap.put(shortAttrName, column);
  -                    requiredColumnsMap.put(shortAttrName,
  -                                           fieldDescs[idx].isPrimaryKey() ? Boolean.TRUE
: Boolean.FALSE);
  +                    // we'll check whether another field (of not necessarily the same name)
  +                    // already maps to this column; if this is the case, we're ignoring
  +                    // this field
  +                    boolean alreadyMapped = false;
  +
  +                    for (Iterator mappedColumnsIt = columnsMap.values().iterator(); mappedColumnsIt.hasNext();)
  +                    {
  +                        if (column.equals(mappedColumnsIt.next()))
  +                        {
  +                            alreadyMapped = true;
  +                            break;
  +                        }
  +                    }
  +                    if (!alreadyMapped)
  +                    {
  +                        String shortAttrName = getShortAttributeName(fieldDescs[idx].getAttributeName());
  +        
  +                        columnsMap.put(shortAttrName, column);
  +                        requiredColumnsMap.put(shortAttrName,
  +                                               fieldDescs[idx].isPrimaryKey() ? Boolean.TRUE
: Boolean.FALSE);
  +                    }
                   }
               }
           }
  @@ -194,7 +236,7 @@
   
                   if (tableName.equals(classDesc.getFullTableName()))
                   {
  -                    elementName = getElementName(classDesc.getClassNameOfObject());
  +                    elementName = getElementName(classDesc);
   
                       FieldDescriptor[] fieldDescs = classDesc.getFieldDescriptions();
   
  @@ -210,7 +252,7 @@
   
               Table   mappedTable        = (Table)_elementToTable.get(elementName);
               TreeMap columnsMap         = (TreeMap)_elementToColumnMap.get(elementName);
  -            HashMap requiredColumnsMap = (HashMap)_elementToRequiredColumnsMap.get(elementName);
  +            HashMap requiredAttributes = (HashMap)_elementToRequiredAttributesMap.get(elementName);
       
               if (mappedTable == null)
               {
  @@ -220,10 +262,10 @@
                       continue;
                   }
                   columnsMap         = new TreeMap();
  -                requiredColumnsMap = new HashMap();
  +                requiredAttributes = new HashMap();
                   _elementToTable.put(elementName, mappedTable);
                   _elementToColumnMap.put(elementName, columnsMap);
  -                _elementToRequiredColumnsMap.put(elementName, requiredColumnsMap);
  +                _elementToRequiredAttributesMap.put(elementName, requiredAttributes);
               }
               for (Iterator columnIt = columns.iterator(); columnIt.hasNext();)
               {
  @@ -233,23 +275,39 @@
                   if (column != null)
                   {
                       columnsMap.put(columnName, column);
  -                    requiredColumnsMap.put(columnName, Boolean.TRUE);
  +                    requiredAttributes.put(columnName, Boolean.TRUE);
                   }
               }
           }
       }
   
       /**
  -     * Adjusts the short (unqualified) class name.
  +     * Returns the element name for the class descriptor which is the adjusted short (unqualified)
class
  +     * name. Also takes care that the element name does not clash with another class of
the same short
  +     * name that maps to a different table though.
        * 
  -     * @param className The (qualified) class name
  -     * @return The short class name
  +     * @param classDesc The class descriptor
  +     * @return The element name
        */
  -    private String getElementName(String className)
  +    private String getElementName(ClassDescriptor classDesc)
       {
  -        String elementName = className.replace('$', '_');
  +        String elementName = classDesc.getClassNameOfObject().replace('$', '_');
   
           elementName = elementName.substring(elementName.lastIndexOf('.') + 1);
  +
  +        Table table  = (Table)_elementToTable.get(elementName);
  +        int   suffix = 0;
  +
  +        while ((table != null) && !table.getName().equals(classDesc.getFullTableName()))
  +        {
  +            ++suffix;
  +            table = (Table)_elementToTable.get(elementName + "-" + suffix);
  +        }
  +        if (suffix > 0)
  +        {
  +            elementName += "-" + suffix;
  +        }
  +
           return elementName;
       }
   
  
  
  
  1.4       +53 -28    db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDatabaseHandling.java
  
  Index: CommonsSqlDatabaseHandling.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDatabaseHandling.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CommonsSqlDatabaseHandling.java	22 Jul 2004 07:48:52 -0000	1.3
  +++ CommonsSqlDatabaseHandling.java	26 Jul 2004 22:25:15 -0000	1.4
  @@ -19,6 +19,8 @@
   import java.util.HashMap;
   import java.util.StringTokenizer;
   
  +import javax.sql.DataSource;
  +
   import org.apache.commons.sql.builder.SqlBuilder;
   import org.apache.commons.sql.builder.SqlBuilderFactory;
   import org.apache.commons.sql.io.DatabaseReader;
  @@ -70,8 +72,6 @@
       private SqlBuilder _builder;
       /** The database schema */
       private Database _schema = new Database();
  -    /** Performs SQL statements */
  -    private DDLExecutor _ddlExecutor;
   
       /**
        * Returns the database type as used by commons-sql.
  @@ -103,21 +103,8 @@
        */
       public void setConnection(JdbcConnectionDescriptor jcd) throws DatabaseHandlingException
       {
  -        _jcd = jcd;
  -
  -        _dataSource = new DataSourceWrapper();
  -
  -        try
  -        {
  -            _dataSource.setDriverClassName(jcd.getDriver());
  -        }
  -        catch (ClassNotFoundException ex)
  -        {
  -            throw new DatabaseHandlingException(ex);
  -        }
  -        _dataSource.setJdbcURL(jcd.getProtocol() + ":" + jcd.getSubProtocol() + ":" + jcd.getDbAlias());
  -        _dataSource.setUserName(jcd.getUserName());
  -        _dataSource.setPassword(jcd.getPassWord());
  +        _jcd         = jcd;
  +        _dataSource  = null;
   
           try
           {
  @@ -127,8 +114,6 @@
           {
               throw new DatabaseHandlingException(ex);
           }
  -
  -        _ddlExecutor = new DDLExecutor(_dataSource, _builder);
       }
   
       /* (non-Javadoc)
  @@ -139,6 +124,45 @@
           return _jcd;
       }
   
  +    /**
  +     * Returns the datasource. Note we're using lazy initialization for the datasource
  +     * (e.g. the first call to this method will initialize it) to enable using the
  +     * sql-generation methods (except dump) without actually having a database (or a
  +     * jdbc driver for it).
  +     * 
  +     * @return The datasource
  +     */
  +    public DataSource getDataSource() throws DatabaseHandlingException
  +    {
  +        if (_dataSource == null)
  +        {
  +            _dataSource = new DataSourceWrapper();
  +
  +            try
  +            {
  +                _dataSource.setDriverClassName(_jcd.getDriver());
  +            }
  +            catch (ClassNotFoundException ex)
  +            {
  +                throw new DatabaseHandlingException(ex);
  +            }
  +            _dataSource.setJdbcURL(_jcd.getProtocol() + ":" + _jcd.getSubProtocol() + ":"
+ _jcd.getDbAlias());
  +            _dataSource.setUserName(_jcd.getUserName());
  +            _dataSource.setPassword(_jcd.getPassWord());
  +        }
  +        return _dataSource;
  +    }
  +
  +    /**
  +     * Returns the DDL executor (a helper object to execute SQL statements).
  +     * 
  +     * @return The DDL executor
  +     */
  +    public DDLExecutor getDDLExecutor() throws DatabaseHandlingException
  +    {
  +        return new DDLExecutor(getDataSource(), _builder);
  +    }
  +
       /* (non-Javadoc)
        * @see org.apache.ojb.broker.util.dbhandling.DatabaseHandling#getMetadata()
        */
  @@ -225,7 +249,7 @@
       {
           try
           {
  -            _ddlExecutor.createDatabase(_schema, true);
  +            getDDLExecutor().createDatabase(_schema, true);
           }
           catch (Exception ex)
           {
  @@ -243,7 +267,7 @@
           try
           {
               getAlterDatabaseSql(writer);
  -            _ddlExecutor.evaluateBatch(writer.getBuffer().toString());
  +            getDDLExecutor().evaluateBatch(writer.getBuffer().toString());
           }
           catch (Exception ex)
           {
  @@ -258,9 +282,9 @@
       {
           try
           {
  -            JdbcModelReader modelReader = new JdbcModelReader(_dataSource.getConnection());
  +            JdbcModelReader modelReader = new JdbcModelReader(getDataSource().getConnection());
   
  -            _ddlExecutor.dropDatabase(modelReader.getDatabase());
  +            getDDLExecutor().dropDatabase(modelReader.getDatabase());
           }
           catch (Exception ex)
           {
  @@ -275,7 +299,7 @@
       {
           try
           {
  -            JdbcModelReader modelReader = new JdbcModelReader(_dataSource.getConnection());
  +            JdbcModelReader modelReader = new JdbcModelReader(getDataSource().getConnection());
   
               new DatabaseWriter(writer).write(modelReader.getDatabase());
           }
  @@ -293,7 +317,7 @@
           _builder.setWriter(writer);
           try
           {
  -            JdbcModelReader modelReader = new JdbcModelReader(_dataSource.getConnection());
  +            JdbcModelReader modelReader = new JdbcModelReader(getDataSource().getConnection());
   
               _builder.dropDatabase(modelReader.getDatabase());
           }
  @@ -311,7 +335,7 @@
           _builder.setWriter(writer);
           try
           {
  -            _builder.alterDatabase(_schema, _dataSource.getConnection(), true, true);
  +            _builder.alterDatabase(_schema, getDataSource().getConnection(), true, true);
           }
           catch (Exception ex)
           {
  @@ -340,7 +364,7 @@
        */
       public void insertData(Reader reader) throws IOException, DatabaseHandlingException
       {
  -        new CommonsSqlDataHandling(_schema, _model).insertData(reader, _ddlExecutor);
  +        new CommonsSqlDataHandling(_schema, _model).insertData(reader, getDataSource());
       }
   
       /* (non-Javadoc)
  @@ -348,6 +372,7 @@
        */
       public void insertData(String srcDir, String listOfFilenames) throws IOException, DatabaseHandlingException
       {
  +        DataSource             dataSource   = getDataSource();
           CommonsSqlDataHandling dataHandling = new CommonsSqlDataHandling(_schema, _model);
           StringTokenizer        tokenizer    = new StringTokenizer(listOfFilenames, ",");
           String                 baseDir      = ((srcDir != null) && (srcDir.length()
> 0) ? srcDir : ".") + "/";
  @@ -359,7 +384,7 @@
               token = tokenizer.nextToken();
               if (token.length() > 0)
               {
  -                dataHandling.insertData(new FileReader(baseDir + token), _ddlExecutor);
  +                dataHandling.insertData(new FileReader(baseDir + token), dataSource);
               }
           }
       }
  
  
  
  1.3       +11 -0     db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DatabaseHandlingTask.java
  
  Index: DatabaseHandlingTask.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DatabaseHandlingTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DatabaseHandlingTask.java	22 Jul 2004 07:48:52 -0000	1.2
  +++ DatabaseHandlingTask.java	26 Jul 2004 22:25:15 -0000	1.3
  @@ -56,6 +56,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Creating the database");
               handler.createDatabase();
           }
       }
  @@ -67,6 +68,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Modifying the database");
               handler.alterDatabase();
           }
       }
  @@ -85,6 +87,7 @@
   
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Inserting data into the database");
               for (Iterator it = _dataFileSets.iterator(); it.hasNext();)
               {
                   FileSet          dataFileSet = (FileSet)it.next();
  @@ -119,6 +122,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Dropping the database");
               handler.dropDatabase();
           }
       }
  @@ -184,6 +188,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Dumping the database");
               try
               {
                   Writer writer = getWriter();
  @@ -205,6 +210,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Generating SQL for creating the database");
               try
               {
                   Writer writer = getWriter();
  @@ -226,6 +232,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Generating SQL for modifying the database");
               try
               {
                   Writer writer = getWriter();
  @@ -247,6 +254,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Generating a DTD for data files");
               try
               {
                   Writer writer = getWriter();
  @@ -275,6 +283,8 @@
   
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Generating SQL for inserting data into the database");
  +
               Writer writer = getWriter();
   
               for (Iterator it = _dataFileSets.iterator(); it.hasNext();)
  @@ -319,6 +329,7 @@
       {
           public void execute(DatabaseHandling handler) throws DatabaseHandlingException
           {
  +            System.out.println("Generating SQL for dropping the database");
               try
               {
                   Writer writer = getWriter();
  
  
  
  1.148     +18 -6     db-ojb/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/build.xml,v
  retrieving revision 1.147
  retrieving revision 1.148
  diff -u -r1.147 -r1.148
  --- build.xml	23 Jul 2004 07:31:56 -0000	1.147
  +++ build.xml	26 Jul 2004 22:25:16 -0000	1.148
  @@ -434,14 +434,26 @@
   
           <dbhandling workdir="${build.test}/ojb">
               <fileset dir="${build.test}" includes="*schema.xml"/>
  -            <!-- We're dumping the sql simply for testing purposes -->
  -            <createSql destFile="${build.test}/test.sql"/>
  -            <!-- This actually creates the database -->
  -            <!-- <create/> -->
  +
  +            <!-- This creates a sql file containing the table definitions -->
  +            <createSql destFile="${build.test}/database.sql"/>
  +
  +            <!-- This creates the database -->
  +            <create/>
  +
  +            <!-- This creates a DTD for data files that fits the repository metadata
and the db schema -->
               <createDataDTD destFile="${build.test}/data.dtd"/>
  -            <insertDataSql>
  +
  +            <!-- This creates a sql file containing insert statements for the specified
data files -->
  +            <insertDataSql destFile="${build.test}/data.sql">
                   <fileset file="${build.test}/ojbtest-data-new.xml"/>
               </insertDataSql>
  +
  +            <!-- This inserts the specified data files into the database -->
  +            <insertData>
  +                <fileset file="${build.test}/ojbtest-data-new.xml"/>
  +            </insertData>
  +
           </dbhandling>
   
       </target>
  
  
  
  1.2       +39 -40    db-ojb/src/schema/ojbtest-data-new.xml
  
  Index: ojbtest-data-new.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-data-new.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ojbtest-data-new.xml	23 Jul 2004 07:31:56 -0000	1.1
  +++ ojbtest-data-new.xml	26 Jul 2004 22:25:16 -0000	1.2
  @@ -114,16 +114,16 @@
       <OrderPosition id="2" order_id="1" article_id="100"/>
       <OrderPosition id="3" order_id="1" article_id="200"/>
   
  -    <Person id="1" firstname="tom" lastname="tom"/>
  -    <Person id="2" firstname="bob" lastname="bob"/>
  -    <Person id="3" firstname="albert" lastname="albert"/>
  -    <Person id="4" firstname="bertrand" lastname="bertrand"/>
  -    <Person id="5" firstname="cindy" lastname="cindy"/>
  -    <Person id="6" firstname="dorothy" lastname="dorothy"/>
  -    <Person id="7" firstname="eugen" lastname="eugen"/>
  -    <Person id="8" firstname="frido" lastname="frido"/>
  -    <Person id="9" firstname="guido" lastname="guido"/>
  -    <Person id="10" firstname="hank%" lastname="hank"/>
  +    <Person-1 id="1" firstname="tom" lastname="tom"/>
  +    <Person-1 id="2" firstname="bob" lastname="bob"/>
  +    <Person-1 id="3" firstname="albert" lastname="albert"/>
  +    <Person-1 id="4" firstname="bertrand" lastname="bertrand"/>
  +    <Person-1 id="5" firstname="cindy" lastname="cindy"/>
  +    <Person-1 id="6" firstname="dorothy" lastname="dorothy"/>
  +    <Person-1 id="7" firstname="eugen" lastname="eugen"/>
  +    <Person-1 id="8" firstname="frido" lastname="frido"/>
  +    <Person-1 id="9" firstname="guido" lastname="guido"/>
  +    <Person-1 id="10" firstname="hank%" lastname="hank"/>
   
       <Project id="1" title="OJB" description="OJB" />
       <Project id="2" title="SODA" description="SODA" />
  @@ -132,44 +132,43 @@
       <Project id="5" title="Linux" description="Linux" />
       <Project id="6" title="mySQL" description="mySQL" />
   
  -    <!-- indirection table! -->
  -    <Role person_id="1" project_id="1" member_id="0" roleName="founder"/>
  -    <Role person_id="1" project_id="2" member_id="0" roleName="friend"/>
  -    <Role person_id="2" project_id="2" member_id="0" roleName="lead"/>
  -    <Role person_id="2" project_id="1" member_id="0" roleName="developer"/>
  -    <Role person_id="2" project_id="3" member_id="0" roleName="developer"/>
  -    <Role person_id="3" project_id="2" member_id="0" roleName="tester"/>
  -    <Role person_id="3" project_id="4" member_id="0" roleName="user"/>
  -    <Role person_id="3" project_id="5" member_id="0" roleName="developer"/>
  -    <Role person_id="4" project_id="1" member_id="0" roleName="developer"/>
  -    <Role person_id="5" project_id="2" member_id="0" roleName="tester"/>
  -    <Role person_id="5" project_id="4" member_id="0" roleName="lead"/>
  -    <Role person_id="7" project_id="4" member_id="0" roleName="lead"/>
  -    <Role person_id="7" project_id="5" member_id="0" roleName="founder"/>
  -    <Role person_id="7" project_id="6" member_id="0" roleName="tester"/>
  +    <Role member_id="1" project_id="1" roleName="founder"/>
  +    <Role member_id="1" project_id="2" roleName="friend"/>
  +    <Role member_id="2" project_id="2" roleName="lead"/>
  +    <Role member_id="2" project_id="1" roleName="developer"/>
  +    <Role member_id="2" project_id="3" roleName="developer"/>
  +    <Role member_id="3" project_id="2" roleName="tester"/>
  +    <Role member_id="3" project_id="4" roleName="user"/>
  +    <Role member_id="3" project_id="5" roleName="developer"/>
  +    <Role member_id="4" project_id="1" roleName="developer"/>
  +    <Role member_id="5" project_id="2" roleName="tester"/>
  +    <Role member_id="5" project_id="4" roleName="lead"/>
  +    <Role member_id="7" project_id="4" roleName="lead"/>
  +    <Role member_id="7" project_id="5" roleName="founder"/>
  +    <Role member_id="7" project_id="6" roleName="tester"/>
   
  -    <Task task_id="1" person_id="2" project_id="1" taskName="Initial Layout"/>
  -    <Task task_id="2" person_id="2" project_id="1" taskName="Initial Spec"/>
  -    <Task task_id="3" person_id="2" project_id="2" taskName="Project Cleanup"/>
  -    <Task task_id="4" person_id="2" project_id="3" taskName="Testing Scripts"/>
  +    <Task task_id="1" member_id="2" project_id="1" taskName="Initial Layout"/>
  +    <Task task_id="2" member_id="2" project_id="1" taskName="Initial Spec"/>
  +    <Task task_id="3" member_id="2" project_id="2" taskName="Project Cleanup"/>
  +    <Task task_id="4" member_id="2" project_id="3" taskName="Testing Scripts"/>
   
  -    <FieldConversionTest_2_ConversionReferrer pk1="1" ref1="50" testId"10"/>
  +    <FieldConversionTest_2_ConversionReferrer pk1="1" ref1="50" testId="10"/>
       <FieldConversionTest_2_ConversionReferrer pk1="2" ref1="51" testId="11"/>
       <FieldConversionTest_2_ConversionReferrer pk1="3" ref1="52" testId="12"/>
       <FieldConversionTest_2_ConversionReferred pk1="50" testId="60"/>
       <FieldConversionTest_2_ConversionReferred pk1="51" testId="61"/>
       <FieldConversionTest_2_ConversionReferred pk1="52" testId="62"/>
   
  -    <SMMaxA id="120" name="A"/>
  -    <SMMaxA id="121" name="A"/>
  -    <SMMaxAA id="101" name="AA"/>
  -    <SMMaxAA id="102" name="AA"/>
  -    <SMMaxAAA id="123" name="AAA"/>
  -    <SMMaxAB id="99" name="AB"/>
  -    <SMMaxB id="115" name="B"/>
  -    <SMMaxB id="116" name="B"/>
  -    <SMMaxBB id="130" name="BB"/>
  -    <SMMaxBB id="131" name="BB"/>
  +    <Repository_SMMaxA id="120" name="A"/>
  +    <Repository_SMMaxA id="121" name="A"/>
  +    <Repository_SMMaxAA id="101" name="AA"/>
  +    <Repository_SMMaxAA id="102" name="AA"/>
  +    <Repository_SMMaxAAA id="123" name="AAA"/>
  +    <Repository_SMMaxAB id="99" name="AB"/>
  +    <Repository_SMMaxB id="115" name="B"/>
  +    <Repository_SMMaxB id="116" name="B"/>
  +    <Repository_SMMaxBB id="130" name="BB"/>
  +    <Repository_SMMaxBB id="131" name="BB"/>
   
       <News id="1" headline="Healf Care News (NONE)"/>
       <News id="2" headline="Ferrai for sale (CARS - BUYERS)"/>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message