cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/ojb/WEB-INF/classes repository.xml
Date Wed, 08 Oct 2003 16:42:44 GMT
antonio     2003/10/08 09:42:44

  Modified:    src/blocks/ojb/mocks/javax/jdo PersistenceManager.java
               src/blocks/ojb/samples/woody employee.js employee.xml
               lib      jars.xml
               src/blocks/ojb/WEB-INF/classes repository.xml
  Added:       src/blocks/ojb/mocks/javax/jdo Transaction.java
               src/blocks/ojb/lib db-ojb-1.0.rc4-20031008.jar
               src/blocks/ojb/java/org/apache/cocoon/ojb/samples
                        EmployeeImpl.java
  Removed:     src/blocks/ojb/lib db-ojb-1.0.rc4-20030926.jar
  Log:
  OJB Block: Woody sample finally working :)
  
  Revision  Changes    Path
  1.2       +17 -2     cocoon-2.1/src/blocks/ojb/mocks/javax/jdo/PersistenceManager.java
  
  Index: PersistenceManager.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/mocks/javax/jdo/PersistenceManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersistenceManager.java	28 Sep 2003 04:31:11 -0000	1.1
  +++ PersistenceManager.java	8 Oct 2003 16:42:43 -0000	1.2
  @@ -1,10 +1,25 @@
   package javax.jdo;
   
  +import java.util.Collection;
  +
   /**
    * Mock class providing the declarations required to compile the Cocoon code when
    * the actual library is not present.
    * 
    * @version CVS $Id$
    */
  -public class PersistenceManager {
  +abstract public interface PersistenceManager {
  +	abstract void close();
  +	abstract public Transaction currentTransaction();
  +	abstract public void deletePersistent(Object o);
  +	abstract public void deletePersistentAll(Object[] o);
  +	abstract public void deletePersistentAll(Collection c);
  +	abstract public void evict(Object o);
  +	abstract public void evictAll();
  +	abstract public void evictAll(Object[] o);
  +	abstract public void evict(Collection o);
  +	
  +	
  +	abstract public void makePersistent(Object O);
   }
  +
  
  
  
  1.1                  cocoon-2.1/src/blocks/ojb/mocks/javax/jdo/Transaction.java
  
  Index: Transaction.java
  ===================================================================
  /*
   * Created on 08-oct-2003
   *
   * To change the template for this generated file go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  package javax.jdo;
  
  /**
   * @author agallardo
   *
   * To change the template for this generated type comment go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  abstract public interface Transaction {
  	abstract public void begin();
  	abstract public void commit();
  	abstract public boolean getNonTransactionlaRead();
  	abstract public boolean getNonTransactionlaWrite();
  	abstract public boolean getOptimistic();
  	abstract public PersistenceManager getPersistenceManager();
  	abstract public boolean getRestoreValues();
  	abstract public boolean getRetainValues();
  //	abstract public Synchronization getSynchronization();
  	abstract public boolean isActive();
  	abstract public void rollback();
  	abstract public void setNontransactionalRead(boolean b);
  	abstract public void setNontransactionalWrite(boolean b);
  	abstract public void setOptimistic(boolean b);
  	abstract public void setRestoreValues(boolean b);
  	abstract public void setRetainValues(boolean b);
  //	abstract public void setSynchronization(Synchronization s);
  }
  
  
  
  
  1.2       +12 -16    cocoon-2.1/src/blocks/ojb/samples/woody/employee.js
  
  Index: employee.js
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/samples/woody/employee.js,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- employee.js	28 Sep 2003 04:31:11 -0000	1.1
  +++ employee.js	8 Oct 2003 16:42:44 -0000	1.2
  @@ -1,27 +1,23 @@
   cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
   
   function employeeform_jdo(form) {
  -    var factory = cocoon.getComponent(Packages.org.apache.cocoon.ojb.jdo.components.JdoPMF.ROLE);
  -    var pm = factory.getPersistenceManager();
  -
  -    if (pm == null)
  -        print("Error: Cannot get Persistent Manager\n");
       // Create a empty Bean
       var bean = new Packages.org.apache.cocoon.ojb.samples.Employee();
   	// Fill some initial data to the bean
  -    //bean.setId("2");
  -    //bean.setDepartmentId("2");
  -    //bean.setName("Carlos Chávez");
  -   
  +    bean.setId("35");
  +    bean.setDepartmentId("2");
  +    bean.setName("Bernardo Robelo");
  +    // Load the Bean to the form
       form.load(bean);
  +    // Let woody handle the form
       form.showForm("jdo/woody/employee-form-display");
  +    // Update the Bean based on user input
   	form.save(bean);
  -	// Save the bean using JDO
  -	var tx = pm.currentTransaction();
  -	tx.begin();
  -	pm.makePersistence(bean);
  -	tx.commit();
  +	var factory = cocoon.getComponent(Packages.org.apache.cocoon.ojb.jdo.components.JdoPMF.ROLE);
  +    // Get persistent Manager
  +	var dbManage = Packages.org.apache.cocoon.ojb.samples.EmployeeImpl();
  +	dbManage.saveEmployee(bean, factory);
   	cocoon.releaseComponent(factory);
  -    // cocoon.request.setAttribute("employeeform", form.getWidget());
  -    cocoon.sendPage("jdo/woody/employee-form-success", {"employeeform": bean});
  +    cocoon.request.setAttribute("employeeform", form.getWidget());
  +    cocoon.sendPage("jdo/woody/employee-form-success");
   }
  
  
  
  1.2       +6 -9      cocoon-2.1/src/blocks/ojb/samples/woody/employee.xml
  
  Index: employee.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/samples/woody/employee.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- employee.xml	28 Sep 2003 04:31:11 -0000	1.1
  +++ employee.xml	8 Oct 2003 16:42:44 -0000	1.2
  @@ -61,9 +61,9 @@
   
       <wd:field id="id" required="true">
           <wd:label>ID :</wd:label>
  -        <wd:datatype base="long">
  -            <wd:validation>
  -                <wd:range min="0"/>
  +        <wd:datatype base="integer">
  +        <wd:validation>
  +                <wd:range min="5"/>
               </wd:validation>
           </wd:datatype>
       </wd:field>
  @@ -79,10 +79,7 @@
   
       <wd:field id="department_id">
           <wd:label>deparment ID :</wd:label>
  -        <wd:datatype base="long">
  -            <wd:validation>
  -                <wd:range min="0"/>
  -            </wd:validation>
  +        <wd:datatype base="integer">
           </wd:datatype>
       </wd:field>
   
  
  
  
  1.1                  cocoon-2.1/src/blocks/ojb/lib/db-ojb-1.0.rc4-20031008.jar
  
  	<<Binary file>>
  
  
  1.111     +2 -2      cocoon-2.1/lib/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/lib/jars.xml,v
  retrieving revision 1.110
  retrieving revision 1.111
  diff -u -r1.110 -r1.111
  --- jars.xml	2 Oct 2003 23:29:48 -0000	1.110
  +++ jars.xml	8 Oct 2003 16:42:44 -0000	1.111
  @@ -892,7 +892,7 @@
   	    for Java Objects against relational databases.
   	</description>
   	<used-by>OJB</used-by>
  -	<lib>ojb/lib/db-ojb-1.0.rc4-20030926.jar</lib>
  +	<lib>ojb/lib/db-ojb-1.0.rc4-20031008.jar</lib>
   	<homepage>http://db.apache.org/ojb/</homepage>
     </file>
     <!-- OJB block end (6-Aug-2003) -->
  
  
  
  1.1                  cocoon-2.1/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/EmployeeImpl.java
  
  Index: EmployeeImpl.java
  ===================================================================
  /*
   * Created on 08-oct-2003
   *
   * To change the template for this generated file go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  package org.apache.cocoon.ojb.samples;
  
  import javax.jdo.PersistenceManager;
  import javax.jdo.Transaction;
  
  import org.apache.cocoon.ojb.jdo.components.JdoPMF;
  
  /**
   * @author agallardo
   *
   * To change the template for this generated type comment go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  public class EmployeeImpl {
  	private Employee emp;
  	
  	public EmployeeImpl(){}
  	
  	public Employee loadEmployee() {
  		return emp;
  	}
  	
  	public void saveEmployee(Employee e, JdoPMF pmf) {
  		// Setting up the Bean 
  		emp = e;
  		/* 1. Get the PersistenceManager */
  		PersistenceManager persistenceManager = pmf.getPersistenceManager();
  		// 2. Get current transaction
  		Transaction tx = persistenceManager.currentTransaction();
  		// 3. Start a Transaction
  		tx.begin();
  		// 4. now perform persistence operations. Store the Employee
  		persistenceManager.makePersistent(emp);
  		// 5. Commit the transaction
  		tx.commit();
  	}
  }
  
  
  
  1.2       +2 -2      cocoon-2.1/src/blocks/ojb/WEB-INF/classes/repository.xml
  
  Index: repository.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/WEB-INF/classes/repository.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- repository.xml	28 Sep 2003 04:31:11 -0000	1.1
  +++ repository.xml	8 Oct 2003 16:42:44 -0000	1.2
  @@ -47,10 +47,10 @@
           <field-descriptor name="id"   column="ID"   jdbc-type="INTEGER" primarykey="true"/>
           <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>
       </class-descriptor>
  -      
  +
       <class-descriptor class="org.apache.cocoon.ojb.samples.Employee" table="EMPLOYEE">
           <field-descriptor name="id"             column="ID"             jdbc-type="INTEGER"
primarykey="true"/>
  -        <field-descriptor name="departamentId" column="DEPARTMENT_ID" jdbc-type="VARCHAR"/>
  +        <field-descriptor name="departmentId" column="DEPARTMENT_ID" jdbc-type="VARCHAR"/>
           <field-descriptor name="name"           column="NAME"           jdbc-type="VARCHAR"/>
      </class-descriptor>
   
  
  
  

Mime
View raw message