db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From florianbruck...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb DBCatalog.java DBColumn.java DBFKRelation.java DBMeta.java DBSchema.java DBTable.java
Date Tue, 28 Jan 2003 21:42:54 GMT
florianbruckner    2003/01/28 13:42:54

  Modified:    src/java/org/apache/ojb/tools/mapping/reversedb
                        DBCatalog.java DBColumn.java DBFKRelation.java
                        DBMeta.java DBSchema.java DBTable.java
  Log:
  update XML generation
  
  Revision  Changes    Path
  1.4       +17 -2     jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBCatalog.java
  
  Index: DBCatalog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBCatalog.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DBCatalog.java	28 Jan 2003 19:59:14 -0000	1.3
  +++ DBCatalog.java	28 Jan 2003 21:42:53 -0000	1.4
  @@ -139,7 +139,19 @@
         String strSchemaName = rs.getString("TABLE_SCHEM");
         // Fix for IBM Informix JDBC 2.21JC2; Schema is padded with spaces, needs to be trimmed
         strSchemaName = strSchemaName.trim();
  -      this.hmSchemas.put(strSchemaName, new DBSchema(dbMeta, this, strSchemaName));
  +      try
  +      {
  +        if (new org.apache.regexp.RE(this.getDBMeta().getSchemaPattern()).match(strSchemaName))
  +        {
  +          this.hmSchemas.put(strSchemaName, new DBSchema(dbMeta, this, strSchemaName));
  +        }
  +      }
  +      catch (org.apache.regexp.RESyntaxException ex)
  +      {
  +        // This expception should be reported, but this does not fit currently.
  +        ex.printStackTrace();
  +      }
  +      
       }
       // Fix for MySQL: Create an empty schema
       if (count == 0)
  @@ -271,6 +283,9 @@
   
   /***************************** Changelog *****************************
    * // $Log$
  + * // Revision 1.4  2003/01/28 21:42:53  florianbruckner
  + * // update XML generation
  + * //
    * // Revision 1.3  2003/01/28 19:59:14  florianbruckner
    * // some updates to schema reading to make it a bit more compatible
    * //
  
  
  
  1.4       +11 -8     jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBColumn.java
  
  Index: DBColumn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBColumn.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DBColumn.java	28 Jan 2003 19:59:14 -0000	1.3
  +++ DBColumn.java	28 Jan 2003 21:42:53 -0000	1.4
  @@ -250,16 +250,16 @@
       if (this.isTreeEnabled())
       {
         String strReturn =  
  -          "  <FieldDescriptor id=\"" + this.id + "\">" + System.getProperty("line.separator")
  -       +  "    <field.name>" + this.strJavaFieldName + "</field.name>" + System.getProperty("line.separator")
  -       +  "    <column.name>" + this.strColumnName + "</column.name>" + System.getProperty("line.separator")
  -       +  "    <jdbc_type>" + Utilities.hmJDBCTypeToName.get(new Integer(this.iColumnType))
+ "</jdbc_type>" + System.getProperty("line.separator");
  +          "  <field-descriptor id=\"" + this.id + "\"" + System.getProperty("line.separator")
  +       +  "    name=\"" + this.strJavaFieldName + "\"" + System.getProperty("line.separator")
  +       +  "    column=\"" + this.strColumnName + "\"" + System.getProperty("line.separator")
  +       +  "    jdbc-type=\"" + Utilities.hmJDBCTypeToName.get(new Integer(this.iColumnType))
+ "\"" + System.getProperty("line.separator");
         if (this.isPrimaryKeyPart())
  -          strReturn += "    <PrimaryKey>true</PrimaryKey>" + System.getProperty("line.separator");
  +          strReturn += "    primarykey=\"true\"" + System.getProperty("line.separator");
         if (this.getAutoIncrement())
             strReturn += "    <autoincrement>true</autoincrement>" + System.getProperty("line.separator");
  -      strReturn += "  </FieldDescriptor>";
  -      return strReturn;
  +      strReturn += "  />";
  +      return strReturn;      
       }
       else return "";
     }  
  @@ -313,6 +313,9 @@
   
   /***************************** Changelog *****************************
   // $Log$
  +// Revision 1.4  2003/01/28 21:42:53  florianbruckner
  +// update XML generation
  +//
   // Revision 1.3  2003/01/28 19:59:14  florianbruckner
   // some updates to schema reading to make it a bit more compatible
   //
  
  
  
  1.3       +31 -20    jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBFKRelation.java
  
  Index: DBFKRelation.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBFKRelation.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DBFKRelation.java	17 Jun 2002 19:34:33 -0000	1.2
  +++ DBFKRelation.java	28 Jan 2003 21:42:53 -0000	1.3
  @@ -311,34 +311,38 @@
     private String getXMLReference()
     {
       String strReturn = "";
  -    strReturn += "  <ReferenceDescriptor id=\"" + this.id + "\">" + System.getProperty("line.separator");
   
  -    strReturn += "    <rdfield.name>" + this.getFieldName() + "</rdfield.name>"
+ System.getProperty("line.separator");
  -    strReturn += "    <referenced.class>" + this.getPKTable().getFQClassName() +
"</referenced.class>" + System.getProperty("line.separator");
  -    strReturn += "    <fk_descriptor_ids>";
  +    strReturn += "  <reference-descriptor" + System.getProperty("line.separator"); 
  
  +    strReturn += "    name=\"" + this.getFieldName() + "\"" + System.getProperty("line.separator");
  +    strReturn += "    class-ref=\"" + this.getPKTable().getFQClassName() + "\"" + System.getProperty("line.separator");
  +    strReturn += "    auto-retrieve=\"" + this.getAutoRetrieve() + "\"" + System.getProperty("line.separator");
   
  +    strReturn += "    auto-update=\"" + this.getAutoUpdate() + "\"" + System.getProperty("line.separator");
   
  +    strReturn += "    auto-delete=\"" + this.getAutoDelete() + "\">" + System.getProperty("line.separator");
  +
  +    strReturn += "<foreignkey field-id-ref=\"";
       java.util.Iterator it = this.getColumnPairIterator();
  -    while (it.hasNext()) strReturn += ((DBColumn)((Object[])it.next())[1]).getId() + "
";
  -    strReturn += "    </fk_descriptor_ids>" + System.getProperty("line.separator");
  -    strReturn += "    <auto.retrieve>" + this.getAutoRetrieve() + "</auto.retrieve>"
+ System.getProperty("line.separator");    
  -    strReturn += "    <auto.update>" + this.getAutoUpdate() + "</auto.update>"
+ System.getProperty("line.separator");    
  -    strReturn += "    <auto.delete>" + this.getAutoDelete() + "</auto.delete>"
+ System.getProperty("line.separator");        
  -    strReturn += "  </ReferenceDescriptor>" + System.getProperty("line.separator");
   
  +    // TODO: dtd dictate one refid
  +    // while (it.hasNext()) strReturn += ((DBColumn)((Object[])it.next())[1]).getId() +
" ";
  +    if (it.hasNext()) strReturn += ((DBColumn)((Object[])it.next())[1]).getId() ;
  +    strReturn += "\" />" + System.getProperty("line.separator");
  +
  +    strReturn += "  </reference-descriptor>" + System.getProperty("line.separator");
       return strReturn;
     }
     
     private String getXMLCollection()
     {
       String strReturn = "";
  -    strReturn += "  <CollectionDescriptor id=\"" + this.id + "\">" + System.getProperty("line.separator");
   
  -    strReturn += "    <cdfield.name>" + this.getFieldName() + "</cdfield.name>"
+ System.getProperty("line.separator");    
  -    strReturn += "    <items.class>" + this.getFKTable().getFQClassName() + "</items.class>"
+ System.getProperty("line.separator");
  -    strReturn += "    <inverse_fk_descriptor_ids>";
  +    strReturn += "  <collection-descriptor" + System.getProperty("line.separator");
   
  +    strReturn += "    name=\"" + this.getFieldName() + "\"" + System.getProperty("line.separator");
   
  +    strReturn += "    element-class-ref=\"" + this.getFKTable().getFQClassName() + "\""
+ System.getProperty("line.separator");
  +    strReturn += "    auto-retrieve=\"" + this.getAutoRetrieve() + "\"" + System.getProperty("line.separator");
   
  +    strReturn += "    auto-update=\"" + this.getAutoUpdate() + "\"" + System.getProperty("line.separator");
   
  +    strReturn += "    auto-delete=\"" + this.getAutoDelete() + "\">" + System.getProperty("line.separator");
   
  +    strReturn += "    <inverse-foreignkey field-id-ref=\"";
       java.util.Iterator it = this.getColumnPairIterator();
       while (it.hasNext()) strReturn += ((DBColumn)((Object[])it.next())[1]).getId() + "
";
  -    strReturn += "    </inverse_fk_descriptor_ids>" + System.getProperty("line.separator");
  -    strReturn += "    <auto.retrieve>" + this.getAutoRetrieve() + "</auto.retrieve>"
+ System.getProperty("line.separator");    
  -    strReturn += "    <auto.update>" + this.getAutoUpdate() + "</auto.update>"
+ System.getProperty("line.separator");    
  -    strReturn += "    <auto.delete>" + this.getAutoDelete() + "</auto.delete>"
+ System.getProperty("line.separator");    
  -    strReturn += "  </CollectionDescriptor>" + System.getProperty("line.separator");
  +    strReturn += "\"    />" + System.getProperty("line.separator");
  +    strReturn += "  </collection-descriptor>" + System.getProperty("line.separator");
       return strReturn;
     }
     
  @@ -408,6 +412,9 @@
   
   /***************************** Changelog *****************************
   // $Log$
  +// Revision 1.3  2003/01/28 21:42:53  florianbruckner
  +// update XML generation
  +//
   // Revision 1.2  2002/06/17 19:34:33  jvanzyl
   // Correcting all the package references.
   // PR:
  
  
  
  1.4       +40 -17    jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBMeta.java
  
  Index: DBMeta.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBMeta.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DBMeta.java	28 Jan 2003 19:59:14 -0000	1.3
  +++ DBMeta.java	28 Jan 2003 21:42:53 -0000	1.4
  @@ -102,6 +102,11 @@
         this(null, null, pDbMeta);
     }
     
  +  public String getSchemaPattern()
  +  {
  +    return this.schemaPattern;
  +  }
  +  
     public boolean isEnabled()
     {
       return this.enabled;
  @@ -193,8 +198,19 @@
       {
           count++;
           String strCatalogName = rs.getString("TABLE_CAT");
  -        DBCatalog aDBCatalog = new DBCatalog(dbMeta, this, strCatalogName);
  -        this.hmCatalogs.put(strCatalogName, aDBCatalog);
  +        try
  +        {
  +          if (new org.apache.regexp.RE(this.catalogPattern).match(strCatalogName))
  +          {
  +            DBCatalog aDBCatalog = new DBCatalog(dbMeta, this, strCatalogName);
  +            this.hmCatalogs.put(strCatalogName, aDBCatalog);
  +          }
  +        }
  +        catch (org.apache.regexp.RESyntaxException ex)
  +        {
  +          // This expception should be reported, but this does not fit currently.
  +          ex.printStackTrace();
  +        }
       }
       rs.close();
       if (count==0)
  @@ -270,25 +286,29 @@
   
     public String getXML()
     {
  -    String strReturn = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + System.getProperty("line.separator");
  -    strReturn += "<!DOCTYPE MappingRepository SYSTEM \"repository.dtd\">" + System.getProperty("line.separator");
  -    strReturn += "<MappingRepository>" + System.getProperty("line.separator");
  -    strReturn += "  <JdbcConnectionDescriptor id =\"default\">" + System.getProperty("line.separator");
  -    strReturn += "    <dbms.name>XXXX</dbms.name>" + System.getProperty("line.separator");
  -    strReturn += "    <driver.name>XXX</driver.name>" + System.getProperty("line.separator");
  -    strReturn += "    <url.protocol>XXX</url.protocol>" + System.getProperty("line.separator");
  -    strReturn += "    <url.subprotocol>XXX</url.subprotocol>" + System.getProperty("line.separator");
  -    strReturn += "    <url.dbalias>XXX</url.dbalias>" + System.getProperty("line.separator");
  -    strReturn += "    <user.name>XXX</user.name>" + System.getProperty("line.separator");
  -    strReturn += "    <user.passwd>XXX</user.passwd>" + System.getProperty("line.separator");
  -    strReturn += "  </JdbcConnectionDescriptor>" + System.getProperty("line.separator");
  -
  +    String strReturn = "";
  +    strReturn = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + System.getProperty("line.separator");
  +    strReturn += "<!DOCTYPE descriptor-repository SYSTEM \"repository.dtd\">" + System.getProperty("line.separator");
  +    strReturn += "<descriptor-repository version=\"0.9.9\">" + System.getProperty("line.separator");
  +    strReturn += "  <jdbc-connection-descriptor" + System.getProperty("line.separator");
  +    strReturn += "    jcd-alias=\"default\"" + System.getProperty("line.separator");
  +    strReturn += "    default-connection=\"true\"" + System.getProperty("line.separator");
  +    strReturn += "    platform=\"XXXX\"" + System.getProperty("line.separator");
  +    strReturn += "    jdbc-level=\"1.0\"" + System.getProperty("line.separator");
  +    strReturn += "    driver=\"XXX\"" + System.getProperty("line.separator");
  +    strReturn += "    protocol=\"XXX\"" + System.getProperty("line.separator");
  +    strReturn += "    subprotocol=\"XXX\"" + System.getProperty("line.separator");
  +    strReturn += "    dbalias=\"XXX\"" + System.getProperty("line.separator");
  +    strReturn += "    username=\"XXX\"" + System.getProperty("line.separator");
  +    strReturn += "    password=\"XXX\">" + System.getProperty("line.separator");
  +    strReturn += "  </jdbc-connection-descriptor>" + System.getProperty("line.separator");
  +    
       Iterator i = this.hmCatalogs.values().iterator();
       while (i.hasNext())
       {
         strReturn += ((DBCatalog)i.next()).getXML() + System.getProperty("line.separator");
       }
  -    return strReturn + "</MappingRepository>";
  +    return strReturn + "</descriptor-repository>";
     }
     
     public void generateJava (java.io.File aFile, String strHeader, String strFooter) throws
java.io.IOException, java.io.FileNotFoundException
  @@ -314,6 +334,9 @@
   
   /***************************** Changelog *****************************
   // $Log$
  +// Revision 1.4  2003/01/28 21:42:53  florianbruckner
  +// update XML generation
  +//
   // Revision 1.3  2003/01/28 19:59:14  florianbruckner
   // some updates to schema reading to make it a bit more compatible
   //
  
  
  
  1.4       +6 -2      jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBSchema.java
  
  Index: DBSchema.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBSchema.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DBSchema.java	28 Jan 2003 19:59:14 -0000	1.3
  +++ DBSchema.java	28 Jan 2003 21:42:53 -0000	1.4
  @@ -121,11 +121,12 @@
         String strSchemaName = rs.getString("TABLE_SCHEM");
         String strTableName = rs.getString("TABLE_NAME");
         String strTableType = rs.getString("TABLE_TYPE");
  -      if (
  +      if (   
                (strTableCat == null && this.getDBCatalog().getCatalogName() == null
|| strTableCat.equals(this.getDBCatalog().getCatalogName()))
              &&(strSchemaName == null && this.getSchemaName() == null ||
strSchemaName.equals(this.getSchemaName()))
            )
           this.addTable(strTableName, strTableType);
  +      
       }
       rs.close();
       
  @@ -271,6 +272,9 @@
   
   /***************************** Changelog *****************************
   // $Log$
  +// Revision 1.4  2003/01/28 21:42:53  florianbruckner
  +// update XML generation
  +//
   // Revision 1.3  2003/01/28 19:59:14  florianbruckner
   // some updates to schema reading to make it a bit more compatible
   //
  
  
  
  1.4       +9 -12     jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBTable.java
  
  Index: DBTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBTable.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DBTable.java	28 Jan 2003 19:59:14 -0000	1.3
  +++ DBTable.java	28 Jan 2003 21:42:53 -0000	1.4
  @@ -91,7 +91,6 @@
       id = IdGeneratorSingleton.getId(this.getClass().getName(), this.getClass().getName());
       aSchema = paSchema;
       dbMeta = pdbMeta;
  -    System.err.println(System.currentTimeMillis() + ": >> New Table " + this.getDBSchema().getDBCatalog().getCatalogName()
+ ":" + this.getDBSchema().getSchemaName() + ":" + this.getTableName());    
     }
     
     public boolean hasDynamicProxy()
  @@ -487,20 +486,15 @@
       if (this.isTreeEnabled())
       {
         java.util.Iterator it = tmColumns.values().iterator();
  -      int colCount = 0;
  -      while (it.hasNext())
  -      {
  -        if (((DBColumn)it.next()).isTreeEnabled()) colCount++;
  -      }
  -      if (colCount > 0)
  +      if (it.hasNext())     
         {
           // Generate the class descriptor
           strReturn +=
  -          "<ClassDescriptor id=\"" + this.id + "\">" + System.getProperty("line.separator");
  +          "<class-descriptor " + System.getProperty("line.separator");
           strReturn +=
  -          "  <class.name>" + this.getFQClassName() + "</class.name>" + System.getProperty("line.separator");
  +          "  class=\"" + this.getFQClassName() + "\"" + System.getProperty("line.separator");
           strReturn +=
  -          "  <table.name>" + this.getFQTableName() + "</table.name>" + System.getProperty("line.separator");
  +          "  table=\"" + this.getFQTableName() + "\">" + System.getProperty("line.separator");
           if (this.hasDynamicProxy())
             strReturn += "  <class.proxy>dynamic</class.proxy>" + System.getProperty("line.separator");
           if (this.getConversionStrategyClass () != null 
  @@ -527,7 +521,7 @@
           {
             strReturn += ((DBFKRelation)it.next()).getXML() + System.getProperty("line.separator");
           }        
  -        strReturn += "</ClassDescriptor>" + System.getProperty("line.separator");
       
  +        strReturn += "</class-descriptor>" + System.getProperty("line.separator");
       
         }
       }
       return strReturn;
  @@ -626,6 +620,9 @@
   
   /***************************** Changelog *****************************
   // $Log$
  +// Revision 1.4  2003/01/28 21:42:53  florianbruckner
  +// update XML generation
  +//
   // Revision 1.3  2003/01/28 19:59:14  florianbruckner
   // some updates to schema reading to make it a bit more compatible
   //
  
  
  

Mime
View raw message