haul        2002/06/10 01:34:45

  Modified:    src/java/org/apache/cocoon/acting/modular
                        DatabaseAction.java
  Log:
    <action dev="CH" type="update">
     DatabaseActions, changed behaviour: Tables are used in order of appearance
     in tableset, before they were used in order of appearance in tables section.
    </action>
  
  Revision  Changes    Path
  1.6       +29 -28    
xml-cocoon2/src/java/org/apache/cocoon/acting/modular/DatabaseAction.java
  
  Index: DatabaseAction.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/modular/DatabaseAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DatabaseAction.java       7 Jun 2002 08:50:15 -0000       1.5
  +++ DatabaseAction.java       10 Jun 2002 08:34:45 -0000      1.6
  @@ -141,7 +141,7 @@
    * </table>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Christian Haul</a>
  - * @version CVS $Id: DatabaseAction.java,v 1.5 2002/06/07 08:50:15 haul Exp $
  + * @version CVS $Id: DatabaseAction.java,v 1.6 2002/06/10 08:34:45 haul Exp $
    * @see org.apache.cocoon.components.modules.input
    * @see org.apache.cocoon.components.modules.output
    * @see org.apache.cocoon.components.modules.database
  @@ -666,8 +666,29 @@
   
               Map modeTypes = null;
   
  -            if (tablesetname != null) {
  +            if (tablesetname == null) {
  +                modeTypes = new HashMap(6);
  +                modeTypes.put( MODE_AUTOINCR, "autoincr" );
  +                modeTypes.put( MODE_OTHERS, "others" );
  +                modeTypes.put( MODE_OUTPUT, outputMode );
  +                for (int i=0; i<tables.length; i++) {
  +                    rows += processTable( tables[i], conn, objectModel, results, 
modeTypes );
  +                }
  +            } else {
                   // new set based behaviour
  +
  +                // create index for table names / aliases
  +                Map tableIndex = new HashMap(2*tables.length);
  +                String tableName = null;
  +                Object result = null;
  +                for (int i=0; i<tables.length; i++) {
  +                    tableName = 
tables[i].getAttribute("alias",tables[i].getAttribute("name",""));
  +                    result = tableIndex.put(tableName,new Integer(i));
  +                    if (result != null) {
  +                        throw new IOException("Duplicate table entry for 
"+tableName+" at positions "+result+" and "+i);
  +                    }
  +                }
  +
                   Configuration[] tablesets = conf.getChildren("table-set");
                   String setname = null;
                   boolean found = false;
  @@ -687,39 +708,19 @@
   
                   Configuration[] set = tablesets[j].getChildren("table");
   
  -                // construct a Map that contains the names of the tables
  -                // contained in the requested tableset
  -                set_tables = new HashMap(set.length);
                   for (int i=0; i<set.length; i++) {
                       // look for alternative mode types
                       modeTypes = new HashMap(6);
                       modeTypes.put( MODE_AUTOINCR, set[i].getAttribute( 
"autoincr-mode", "autoincr" ) );
                       modeTypes.put( MODE_OTHERS, set[i].getAttribute( "others-mode", 
  "others" ) );
                       modeTypes.put( MODE_OUTPUT, outputMode );
  -                    set_tables.put(set[i].getAttribute("name",""), modeTypes);
  -                }
  -            } else {
  -                modeTypes = new HashMap(6);
  -                modeTypes.put( MODE_AUTOINCR, "autoincr" );
  -                modeTypes.put( MODE_OTHERS, "others" );
  -                modeTypes.put( MODE_OUTPUT, outputMode );
  -            };
  -
  -            for (int i=0; i<tables.length; i++) {
  -                if (set_tables == null ||
  -                     set_tables.containsKey( tables[i].getAttribute( "name" ) ) ||
  -                     ( tables[i].getAttribute( "alias", null ) != null && 
set_tables.containsKey( tables[i].getAttribute( "alias" ) ) )
  -                     ) {
  -                    if (tablesetname != null) {
  -                        if (tables[i].getAttribute("alias", null) != null && 
set_tables.containsKey(tables[i].getAttribute("alias"))){
  -                            modeTypes = (Map) 
set_tables.get(tables[i].getAttribute("alias"));
  -                            set_tables.remove(tables[i].getAttribute("alias"));
  -                        } else {
  -                            modeTypes = (Map) 
set_tables.get(tables[i].getAttribute("name"));
  -                            set_tables.remove(tables[i].getAttribute("name"));
  -                        }
  +                    tableName=set[i].getAttribute("name","");
  +                    if (tableIndex.containsKey(tableName)) {
  +                        j = ((Integer)tableIndex.get(tableName)).intValue();
  +                        rows += processTable( tables[j], conn, objectModel, 
results, modeTypes );
  +                    } else {
  +                        throw new IOException(" given table " + tableName + " does 
not exists in a description file.");
                       }
  -                    rows += processTable( tables[i], conn, objectModel, results, 
modeTypes );
                   }
               }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to