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 Thu, 09 Oct 2003 18:30:53 GMT
antonio     2003/10/09 11:30:53

  Modified:    src/blocks/ojb/samples sitemap.xmap
               src/blocks/ojb/WEB-INF/classes/org/apache/cocoon/ojb/samples
                        Employee.class Department.class
               src/blocks/ojb/samples/woody employee.js
               src/blocks/ojb/mocks/javax/jdo PersistenceManager.java
               src/blocks/ojb/java/org/apache/cocoon/ojb/samples
                        EmployeeImpl.java
               src/blocks/ojb/WEB-INF/classes repository.xml
  Added:       src/blocks/ojb/mocks/javax/jdo Extent.java Query.java
  Log:
  Updating OJB samples.
  
  Revision  Changes    Path
  1.2       +1 -1      cocoon-2.1/src/blocks/ojb/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/samples/sitemap.xmap,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- sitemap.xmap	28 Sep 2003 04:31:10 -0000	1.1
  +++ sitemap.xmap	9 Oct 2003 18:30:52 -0000	1.2
  @@ -64,7 +64,7 @@
      </map:match>
   
        <!--
  -        | "Form1" example, demonstrates usega of flow and woody
  +        | "Form1" example, demonstrates usage of flow and woody
           -->
   
       <map:match pattern="jdo/woody/employee">
  
  
  
  1.2       +33 -37    cocoon-2.1/src/blocks/ojb/WEB-INF/classes/org/apache/cocoon/ojb/samples/Employee.class
  
  	<<Binary file>>
  
  
  1.2       +2 -2      cocoon-2.1/src/blocks/ojb/WEB-INF/classes/org/apache/cocoon/ojb/samples/Department.class
  
  	<<Binary file>>
  
  
  1.3       +9 -7      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- employee.js	8 Oct 2003 16:42:44 -0000	1.2
  +++ employee.js	9 Oct 2003 18:30:53 -0000	1.3
  @@ -2,21 +2,23 @@
   
   function employeeform_jdo(form) {
       // Create a empty Bean
  +
  +   	var factory = cocoon.getComponent(Packages.org.apache.cocoon.ojb.jdo.components.JdoPMF.ROLE);
       var bean = new Packages.org.apache.cocoon.ojb.samples.Employee();
  +    var ojbEmployee = Packages.org.apache.cocoon.ojb.samples.EmployeeImpl();
   	// Fill some initial data to the bean
  -    bean.setId("35");
  -    bean.setDepartmentId("2");
  -    bean.setName("Bernardo Robelo");
  +    // Load bean based on the given PrimaryKey
  +    bean = ojbEmployee.load(1, factory);
  +
       // 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);
  -	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);
  +
  +    // Save Bean in Database
  +	ojbEmployee.save(bean, factory);
   	cocoon.releaseComponent(factory);
       cocoon.request.setAttribute("employeeform", form.getWidget());
       cocoon.sendPage("jdo/woody/employee-form-success");
  
  
  
  1.3       +48 -3     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PersistenceManager.java	8 Oct 2003 16:42:43 -0000	1.2
  +++ PersistenceManager.java	9 Oct 2003 18:30:53 -0000	1.3
  @@ -17,9 +17,54 @@
   	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 evictAll(Collection o);
  +	abstract public Extent getExtent(Class c, boolean b);
  +	abstract public boolean getIgnoreCache();
  +	abstract public boolean getMultiThreaded();
  +	abstract public Object getObjectById(Object o, boolean b);
  +	abstract public Object getObjectId(Object o);
  +	abstract public Class getObjectIdClass(Class c);
  +	abstract public PersistenceManagerFactory getPersistenceManagerFactory();
  +	abstract public Object getTransactionlaObjectId(Object o);
  +	abstract public Object getUserObjec();
  +	abstract public boolean isClosed();
  +	abstract public void makeNontransactional(Object o);
  +	abstract public void makeNontransactionalAll(Object[] o);
  +	abstract public void makeNontransactionalAll(Collection c);
  +	abstract public void makePersistent(Object O);
  +	abstract public void makePersistentAll(Object[] O);
  +	abstract public void makePersistentAll(Collection O);
  +	abstract public void makeTransactional(Object O);
  +	abstract public void makeTransactionalAll(Object[] O);
  +	abstract public void makeTransactionalAll(Collection O);
  +	abstract public void makeTransient(Object O);
  +	abstract public void makeTransientAll(Object[] O);
  +	abstract public void makeTransientAll(Collection O);
  +	abstract public Object newObjectIdInstance(Class c, String s);
  +	abstract public Query newQuery();
  +	abstract public Query newQuery(Class c);
  +	abstract public Query newQuery(Class c, String s);
  +	abstract public Query newQuery(Class c, Collection co);
  +	abstract public Query newQuery(Class c, Collection co, String s);
  +	abstract public Query newQuery(Object o);
  +	abstract public Query newQuery(String s, Object o);
  +	abstract public Query newQuery(Extent e);
  +	abstract public Query newQuery(Extent e, String s);
  +	abstract public void refresh(Object o);
  +	abstract public void refreshAll();
  +	abstract public void refreshAll(Object[] o);
  +	abstract public void refreshAll(Collection c);
  +	abstract public void retrieve(Object o);
  +	abstract public void retrieveAll(Object[] o);
  +	abstract public void retrieveAll(Collection c);
  +	abstract public void setIgnoreCache(boolean b);
  +	abstract public void setMultithreaded(boolean b);
  +	abstract public void setUserObject(Object o);
  +	
  +	
  +	
  +	
   	
   	
  -	abstract public void makePersistent(Object O);
   }
   
  
  
  
  1.1                  cocoon-2.1/src/blocks/ojb/mocks/javax/jdo/Extent.java
  
  Index: Extent.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 Extent {}
  
  
  
  1.1                  cocoon-2.1/src/blocks/ojb/mocks/javax/jdo/Query.java
  
  Index: Query.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;
  
  import java.util.Collection;
  import java.util.Map;
  
  /**
   * @author agallardo
   *
   * To change the template for this generated type comment go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  abstract public interface Query
  {
  	abstract public void close(Object o);
  	abstract public void closeAll();
  	abstract public void compile();
  	abstract public void declareImports(String s);
  	abstract public void declareParameters(String s);
  	abstract public void declareVariables(String s);
  	abstract public Object execute();
  	abstract public Object execute(Object o);
  	abstract public Object execute(Object o, Object p);
  	abstract public Object execute(Object o, Object p, Object q);
  	abstract public Object executeWithArray(Object[] o);
  	abstract public Object executeWithMap(Map m);
  	abstract public boolean getIgnoreCache();
  	abstract public PersistenceManager getPersistentManager();
  	abstract public void setIgnoreCandidates(Collection c);
  	abstract public void setClass(Class c);
  	abstract public void setFilter(String s);
  	abstract public void setIgnoreCache(boolean b);
  	abstract public void setOrdering(String s);
  	
  	
  	
  }
  
  
  
  1.2       +42 -3     cocoon-2.1/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/EmployeeImpl.java
  
  Index: EmployeeImpl.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/EmployeeImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EmployeeImpl.java	8 Oct 2003 16:42:44 -0000	1.1
  +++ EmployeeImpl.java	9 Oct 2003 18:30:53 -0000	1.2
  @@ -6,7 +6,12 @@
    */
   package org.apache.cocoon.ojb.samples;
   
  +import java.util.Collection;
  +import java.util.Iterator;
  +
  +import javax.jdo.Extent;
   import javax.jdo.PersistenceManager;
  +import javax.jdo.Query;
   import javax.jdo.Transaction;
   
   import org.apache.cocoon.ojb.jdo.components.JdoPMF;
  @@ -22,11 +27,45 @@
   	
   	public EmployeeImpl(){}
   	
  -	public Employee loadEmployee() {
  -		return emp;
  +	
  +	public Employee load(int id, JdoPMF pmf) {
  +		String filter = "employee.id ==" + id;
  +		/* 1. Get the PersistenceManager */
  +		PersistenceManager persistenceManager = pmf.getPersistenceManager();
  +		Extent extent = persistenceManager.getExtent(Employee.class, true);
  +		Query query = persistenceManager.newQuery(extent, filter);
  +		query.setOrdering("employee.id ascending");
  +		Collection result = (Collection)query.execute();
  +		Iterator iter = result.iterator();
  +		while(iter.hasNext()) {
  +			Employee e = (Employee) iter.next();
  +			if (id == e.getId())
  +				return e;
  +		}
  +		return null;
   	}
   	
  -	public void saveEmployee(Employee e, JdoPMF pmf) {
  +//	public Employee load(int id, JdoPMF pmf) {
  +//		
  +//		/* 1. Get the PersistenceManager */
  +//		PersistenceManager persistenceManager = pmf.getPersistenceManager();
  +//		
  +//		Employee e = new Employee();
  +//		e.setId(id);
  +//		PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +//		Identity oid = new Identity(e, broker);
  +//		
  +//		Employee toBeReturned = new Employee();
  +//		//	2. start transaction
  +//		persistenceManager.currentTransaction().begin();
  +//		// 3. Get the Object based on the primary key
  +//		toBeReturned = (Employee) persistenceManager.getObjectById(oid, false);
  +//		// 4. End transaction
  +//		persistenceManager.currentTransaction().commit();
  +//		return toBeReturned;
  +//	}
  +	
  +	public void save(Employee e, JdoPMF pmf) {
   		// Setting up the Bean 
   		emp = e;
   		/* 1. Get the PersistenceManager */
  
  
  
  1.3       +1 -1      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- repository.xml	8 Oct 2003 16:42:44 -0000	1.2
  +++ repository.xml	9 Oct 2003 18:30:53 -0000	1.3
  @@ -50,7 +50,7 @@
   
       <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="departmentId" column="DEPARTMENT_ID" jdbc-type="VARCHAR"/>
  +        <field-descriptor name="departmentId" column="DEPARTMENT_ID" jdbc-type="INTEGER"/>
           <field-descriptor name="name"           column="NAME"           jdbc-type="VARCHAR"/>
      </class-descriptor>
   
  
  
  

Mime
View raw message