avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/test Tester.java
Date Sun, 04 Nov 2001 19:00:19 GMT
hammant     01/11/04 11:00:19

  Modified:    apps/db/src/java/org/apache/avalon/db/actions Action.java
               apps/db/src/java/org/apache/avalon/db/bcel/actions
                        AbstractBCELAction.java BCELCreateTable.java
               apps/db/src/java/org/apache/avalon/db/bcel/parser
                        LXSQLParser.java
               apps/db/src/java/org/apache/avalon/db/server
                        AbstractDatabaseManager.java
               apps/db/src/java/org/apache/avalon/db/test Tester.java
  Log:
  LXSQL parsing works now.
  
  Revision  Changes    Path
  1.5       +3 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/actions/Action.java
  
  Index: Action.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/actions/Action.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Action.java	2001/10/30 23:15:47	1.4
  +++ Action.java	2001/11/04 19:00:19	1.5
  @@ -9,6 +9,7 @@
   package org.apache.avalon.db.actions;
   
   import org.apache.avalon.db.services.DatabasePersistor;
  +import org.apache.avalon.db.services.SQLParser;
   
   
   /**
  @@ -16,7 +17,8 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.4 $
  + * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
  + * @version * $Revision: 1.5 $
    */
   public interface Action {
       void execute() throws ActionException;
  
  
  
  1.2       +4 -4      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/actions/AbstractBCELAction.java
  
  Index: AbstractBCELAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/actions/AbstractBCELAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractBCELAction.java	2001/10/31 12:43:23	1.1
  +++ AbstractBCELAction.java	2001/11/04 19:00:19	1.2
  @@ -9,18 +9,18 @@
   
   import org.apache.avalon.db.services.DatabasePersistor;
   import org.apache.avalon.db.bcel.parser.GeneratedObjectClassLoader;
  -import org.apache.avalon.db.bcel.parser.BCELSQLParser;
  +import org.apache.avalon.db.bcel.parser.BaseBCELParser;
   
   public class AbstractBCELAction {
   
       protected DatabasePersistor mDatabasePersistor;
  -    protected BCELSQLParser mBCELSQLParser;
  +    protected BaseBCELParser mBCELParser;
   
       public void setDatabasePersistor(DatabasePersistor databasePersistor) {
           mDatabasePersistor = databasePersistor;
       }
  -    public void setBCELSQLParser(BCELSQLParser bcelSQLParser) {
  -        mBCELSQLParser = bcelSQLParser;
  +    public void setBCELParser(BaseBCELParser bcelParser) {
  +        mBCELParser = bcelParser;
       }
   
   }
  
  
  
  1.3       +8 -5      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/actions/BCELCreateTable.java
  
  Index: BCELCreateTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/actions/BCELCreateTable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BCELCreateTable.java	2001/10/31 14:42:14	1.2
  +++ BCELCreateTable.java	2001/11/04 19:00:19	1.3
  @@ -27,7 +27,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class BCELCreateTable extends AbstractBCELAction implements CreateTable {
   
  @@ -58,15 +58,18 @@
        *
        */
       public void execute() throws ActionException {
  +        /*
           if (mDatabasePersistor.tableExists(mTableName)) {
               throw new ActionException("Table " + mTableName + " Already Exists");
           }
  +        */
   
           byte[] bytes = mPendingRowClass.getBytes();
  -        mBCELSQLParser.addGeneratedClass(mTableName, bytes);
  -        Class rowClass = mBCELSQLParser.getGeneratedClass(mTableName);
  -        Table table = new BCELTable(mTableName, (Column[]) mColumns.toArray(), rowClass);
  -        mDatabasePersistor.addTable(mTableName, table);
  +        System.out.println("here 1");
  +        mBCELParser.addGeneratedClass(mTableName, bytes);
  +        //Class rowClass = mBCELSQLParser.getGeneratedClass(mTableName);
  +        //Table table = new BCELTable(mTableName, (Column[]) mColumns.toArray(), rowClass);
  +        //mDatabasePersistor.addTable(mTableName, table);
       }
   
       public int getRecordCount() {
  
  
  
  1.4       +12 -12    jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/LXSQLParser.java
  
  Index: LXSQLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/LXSQLParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LXSQLParser.java	2001/11/04 11:26:14	1.3
  +++ LXSQLParser.java	2001/11/04 19:00:19	1.4
  @@ -21,6 +21,7 @@
   import org.apache.avalon.db.transport.InsertRequest;
   import org.apache.avalon.db.bcel.actions.BCELCreateTable;
   import org.apache.avalon.db.bcel.actions.BCELInsertSingleValue;
  +import org.apache.avalon.db.bcel.actions.AbstractBCELAction;
   import org.apache.avalon.db.bcel.data.BCELTable;
   import org.apache.avalon.db.data.Table;
   import org.apache.avalon.db.data.Column;
  @@ -52,11 +53,13 @@
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Node;
   import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Element;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.ParserConfigurationException;
  +
   import java.util.StringTokenizer;
   import java.util.Vector;
   import java.util.HashMap;
  @@ -71,7 +74,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class LXSQLParser extends BaseBCELParser {
   
  @@ -136,21 +139,17 @@
           String docStr = XMLHDR + request.getSql();
           System.out.println("docStr=" + docStr);
   
  -        //StringReader sr = new StringReader(XMLHDR + request.getSql());
  -        //InputSource is = new InputSource(sr);
  -        //StringReader sr2 = new StringReader(XMLHDR + request.getSql());
  -        ByteArrayInputStream bais = new ByteArrayInputStream(docStr.getBytes());
  +        StringReader sr = new StringReader(docStr);
  +        InputSource is = new InputSource(sr);
   
           try
           {
  -            Document doc = mDocumentBuilder.parse(bais);
  +            Document doc = mDocumentBuilder.parse(is);
  +
  +            Element rootElement = doc.getDocumentElement();
  +            getLogger().debug("rootElement=" + rootElement.getTagName());
   
  -            System.out.println("doc" + doc);
  -            NamedNodeMap nnm = doc.getAttributes();
  -            System.out.println("nnm= " + nnm);
  -            Node n = nnm.getNamedItem("name");
  -            System.out.println("n=" + n);
  -            String tableName = n.getNodeValue();
  +            String tableName = rootElement.getAttribute("name");
   
               NodeList columnNodes = doc.getElementsByTagName("columns/column");
   
  @@ -184,6 +183,7 @@
   
               CreateTable action = new BCELCreateTable(cg.getJavaClass(), tableName, columns);
               action.setDatabasePersistor(mDatabasePersistor);
  +            ((AbstractBCELAction) action).setBCELParser(this);
               return action;
           }
           catch (SAXException se)
  
  
  
  1.10      +6 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/server/AbstractDatabaseManager.java
  
  Index: AbstractDatabaseManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/server/AbstractDatabaseManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractDatabaseManager.java	2001/11/03 15:02:07	1.9
  +++ AbstractDatabaseManager.java	2001/11/04 19:00:19	1.10
  @@ -37,7 +37,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    */
   public abstract class AbstractDatabaseManager extends AbstractLoggable implements Composable
{
   
  @@ -87,6 +87,7 @@
                   break;
               }
           } catch (ActionException ae) {
  +            getLogger().error("processRequest(): Exception",ae);
               return new ExceptionReply(ae.getMessage());
           }
   
  @@ -94,9 +95,12 @@
       }
   
       public Reply processSelectRequest(SelectRequest selectRequest) throws ActionException
{
  +        getLogger().debug("mSQLParser=" + mSQLParser);
  +        /*
           SelectRequest optimizedSelectRequest =
               mSQLOptimizer.optimizeSelectRequest(selectRequest);
  -        Select select = mSQLParser.createSelectAction(optimizedSelectRequest);
  +        */
  +        Select select = mSQLParser.createSelectAction(selectRequest); //optimizedSelectRequest);
           select.execute();
           return new ResultSetReply(select.getRowSet());
       }
  
  
  
  1.4       +1 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/test/Tester.java
  
  Index: Tester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/test/Tester.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Tester.java	2001/11/04 11:26:14	1.3
  +++ Tester.java	2001/11/04 19:00:19	1.4
  @@ -25,7 +25,7 @@
   
       private void test() throws Exception {
           Statement st = mCon.createStatement();
  -        st.executeUpdate("<create-table><table name=\"Fred\"/><columns><column
name=\"wilma\" type=\"varchar\" max=\"20\"/><column name=\"barney\" type=\"varchar\"
max=\"20\"/></columns></create-table>");
  +        st.executeUpdate("<create-table name=\"Fred\"><columns><column name=\"wilma\"
type=\"varchar\" max=\"20\"/><column name=\"barney\" type=\"varchar\" max=\"20\"/></columns></create-table>");
       }
   
       private void close() throws Exception {
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message