You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2001/03/13 18:01:35 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/acting OraAddAction.java DatabaseAddAction.java

bloritsch    01/03/13 09:01:35

  Modified:    src/org/apache/cocoon/acting Tag: xml-cocoon2
                        OraAddAction.java DatabaseAddAction.java
  Log:
  More index fixing.  Dynamically created SQL calls are tough.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.8   +25 -9     xml-cocoon/src/org/apache/cocoon/acting/Attic/OraAddAction.java
  
  Index: OraAddAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/OraAddAction.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- OraAddAction.java	2001/03/12 22:12:33	1.1.2.7
  +++ OraAddAction.java	2001/03/13 17:01:34	1.1.2.8
  @@ -41,7 +41,7 @@
    * only one table at a time to update.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.2.7 $ $Date: 2001/03/12 22:12:33 $
  + * @version CVS $Revision: 1.1.2.8 $ $Date: 2001/03/13 17:01:34 $
    */
   public class OraAddAction extends DatabaseAddAction {
       private static final Map selectLOBStatements = new HashMap();
  @@ -75,6 +75,7 @@
               Configuration[] values = conf.getChild("table").getChild("values").getChildren("value");
               currentIndex = 1;
   
  +            // Insert the keys into the query
               for (int i = 0; i < keys.length; i++) {
                   String mode = keys[i].getAttribute("mode", "automatic");
   
  @@ -100,6 +101,7 @@
                   }
               }
   
  +            // insert the values into the query
               for (int i = 0; i < values.length; i++) {
                   String type = values[i].getAttribute("type");
                   String parameter = values[i].getAttribute("param");
  @@ -131,7 +133,8 @@
               query = this.getSelectLOBQuery(conf);
               getLogger().info(query);
   
  -            if ("".equals(query) == false) {
  +            // Process the large objects if they exist
  +            if (query != null) {
                   PreparedStatement LOBstatement = conn.prepareStatement(query);
                   getLogger().info(query);
   
  @@ -258,27 +261,33 @@
                           if ("manual".equals(mode)) {
                               this.setSelectQuery(table.getAttribute("name"), keys[i]);
                           }
  +
                           numKeys++;
                       }
                   }
   
  -                int numValues = 0;
  -
                   for (int i = 0; i < values.length; i++) {
  -                    if (i > 0) {
  +                    if ((numKeys + i) > 0) {
                           queryBuffer.append(", ");
                       }
   
                       queryBuffer.append(values[i].getAttribute("dbcol"));
  -                    numValues++;
                   }
   
                   queryBuffer.append(") VALUES (");
  +
  +                numKeys = 0;
   
  -                int numParams = numValues + numKeys;
  +                for (int i = 0; i < keys.length; i++) {
  +                    if (numKeys > 0) queryBuffer.append(", ");
  +                    if ("automatic".equals(keys[i].getAttribute("mode", "automatic")) == false) {
  +                        queryBuffer.append("?");
  +                        numKeys++;
  +                    }
  +                }
   
  -                for (int i = 0; i < numParams; i++) {
  -                    if (i > 0) {
  +                for (int i = 0; i < values.length; i++) {
  +                    if ((numKeys + i) > 0) {
                           queryBuffer.append(", ");
                       }
   
  @@ -316,6 +325,7 @@
           synchronized (OraAddAction.selectLOBStatements) {
               query = (String) OraAddAction.selectLOBStatements.get(conf);
   
  +            // executes only if query is null.
               if (query == null) {
                   StringBuffer queryBuffer = new StringBuffer("SELECT ");
                   Configuration table = conf.getChild("table");
  @@ -323,6 +333,7 @@
                   Configuration[] keys = table.getChild("keys").getChildren("key");
                   int numLobs = 0;
   
  +                // Add the values to the query
                   for (int i = 0; i < values.length; i++) {
                       if (this.isLargeObject(values[i].getAttribute("type"))) {
                           numLobs++;
  @@ -337,15 +348,18 @@
   
                   if (numLobs == 0) {
                       query = "";
  +                    // if query is set to "", then it won't try to process it again.
                       OraAddAction.selectLOBStatements.put(conf, query);
                       return query;
                   }
   
                   queryBuffer.append(" FROM ").append(table.getAttribute("name"));
   
  +                // Process the WHERE clause
                   if (keys.length > 0) {
                       queryBuffer.append(" WHERE ");
   
  +                    // Add the keys to the query
                       for (int i = 0; i < keys.length; i++) {
                           if (i > 0) {
                               queryBuffer.append(" AND ");
  @@ -360,6 +374,8 @@
                   OraAddAction.selectLOBStatements.put(conf, query);
               }
           }
  +
  +        if ("".equals(query)) return null;
   
           return query;
       }
  
  
  
  1.1.2.18  +2 -2      xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseAddAction.java
  
  Index: DatabaseAddAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseAddAction.java,v
  retrieving revision 1.1.2.17
  retrieving revision 1.1.2.18
  diff -u -r1.1.2.17 -r1.1.2.18
  --- DatabaseAddAction.java	2001/03/12 22:12:32	1.1.2.17
  +++ DatabaseAddAction.java	2001/03/13 17:01:34	1.1.2.18
  @@ -40,7 +40,7 @@
    * only one table at a time to update.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.2.17 $ $Date: 2001/03/12 22:12:32 $
  + * @version CVS $Revision: 1.1.2.18 $ $Date: 2001/03/13 17:01:34 $
    */
   public class DatabaseAddAction extends AbstractDatabaseAction {
       protected static final Map addStatements = new HashMap();
  @@ -165,7 +165,7 @@
                   int numValues = 0;
   
                   for (int i = 0; i < values.length; i++) {
  -                    if (i > 0) {
  +                    if ((numKeys + numValues) > 0) {
                           queryBuffer.append(", ");
                       }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org