Lance,

Here's a diff of my changes.


On 1/31/07, Lance Waterman <[EMAIL PROTECTED]> wrote:

Hi Maciej,

Just a friendly ping to see if you've had a chance to check in your
changes.

Thanks,

Lance

On 1/26/07, Lance Waterman <[EMAIL PROTECTED]> wrote:
>
> I'm guessing that the fixes should clear up the problems as reported by
> Guillaume? If so please go ahead and check them in and I will work on
> carrying them forward.
>
> Lance
>
> On 1/26/07, Maciej Szefler <[EMAIL PROTECTED] > wrote:
> >
> > Yep, that was the plan. I haven't had a chance to finish it. I can
> > check the files in if you want to take over, but it will break things.
> >
> > -mbs
> > On 1/25/07, Lance Waterman < [EMAIL PROTECTED]> wrote:
> > > sure - sounds good to me
> > >
> > > On another note - are you still looking at replacing some of the
> > iterators
> > > with queries in the JPA impl? Matthieu felt like you might be
swamped
> > so I
> > > just thought I'd check.
> > >
> > > Lance
> > >
> > > On 1/25/07, Maciej Szefler <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Lance,
> > > > I think I fixed the file not found issue, so it prob works now.
But
> > > > its not so nice to have to build these things direcrtly from the
> > > > bpel-test module. We should be able to import the database tarball
> > > > generated from dao-jpa-ojpa-derby module no?
> > > >
> > > >
> > > > On 1/25/07, Lance Waterman <[EMAIL PROTECTED]> wrote:
> > > > > Maciej,
> > > > >
> > > > > It looks like you commented out the DB build task from the
> > bpel-test POM
> > > > ...
> > > > >
> > > > >                     <!-- This is causing a problem, file not
found
> > > > derby.sql
> > > > >                          Let's move this into a separate test
> > module.
> > > > > -Maciej1/2/07
> > > > >                     <execution>
> > > > >                         <id>Generate Derby DB</id>
> > > > >                         <phase>compile</phase>
> > > > >
> > > > >
> > > > >                         <configuration>
> > > > >                             <tasks>
> > > > >                                 <ant antfile=" build.xml"
> > target="db"
> > > > > inheritRefs="true"/>
> > > > >                             </tasks>
> > > > >                         </configuration>
> > > > >                         <goals>
> > > > >                             <goal>run</goal>
> > > > >                         </goals>
> > > > >                     </execution>
> > > > >                     -->
> > > > >
> > > > > Can you give a bit more detail on what you are thinking? ( i.e.
a
> > > > > bpel-test-jpa-derby project )
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Lance
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>


Index: dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java
===================================================================
--- dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java      
(revision 496886)
+++ dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java      
(working copy)
@@ -32,10 +32,12 @@
 @Entity
 @Table(name="ODE_SCOPE")
 public class ScopeDAOImpl implements ScopeDAO {
+    @PersistenceContext EntityManager _em;
        
        @Id @Column(name="SCOPE_ID")
-       @GeneratedValue(strategy=GenerationType.AUTO)
+    @GeneratedValue(strategy=GenerationType.AUTO)
        private Long _scopeInstanceId;
+    
        @Basic @Column(name="MODEL_ID") private int _modelId;
        @Basic @Column(name="SCOPE_NAME") private String _name;
        @Basic @Column(name="SCOPE_STATE") private String _scopeState;
@@ -58,18 +60,12 @@
        @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
        @Column(name="PROCESS_INSTANCE_ID")
        private ProcessInstanceDAOImpl _processInstance;
-       
-       @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
-       @Column(name="CONNECTION_ID")
-       private BPELDAOConnectionImpl _connection;
 
        public ScopeDAOImpl() {}
-       public ScopeDAOImpl(ScopeDAOImpl parentScope, String name, int 
scopeModelId, ProcessInstanceDAOImpl pi, BPELDAOConnectionImpl connection) {
+       public ScopeDAOImpl(ScopeDAOImpl parentScope, String name, int 
scopeModelId, ProcessInstanceDAOImpl pi) {
                _parentScope = parentScope;
                _name = name;
                _modelId = scopeModelId;
-               _connection = connection;
-               _connection.addScope(this);
                _processInstance = pi;
        }
        
@@ -100,7 +96,7 @@
                        ret = new CorrelationSetDAOImpl(this,corrSetName);
                        
                        // Persist the new correlation set to generate an ID
-                       _connection.getEntityManager().persist(ret);
+                       _em.persist(ret);
                        
                        _correlationSets.add(ret);
                }
Index: dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
===================================================================
--- dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java     
(revision 496886)
+++ dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java     
(working copy)
@@ -48,7 +48,7 @@
        private Long _correlationSetId;
        @Basic @Column(name="NAME") private String _name;
        @Basic @Column(name="PROPERTIES") private HashMap<QName,String> _props 
= new HashMap<QName,String>();
-       @Basic @Column(name="CORRELATION_KEY") private CorrelationKey 
_correlationKey;
+       @Basic @Column(name="CORRELATION_KEY") private String _correlationKey;
        @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
        @Column(name="SCOPE_ID")
        private ScopeDAOImpl _scope;
@@ -77,11 +77,11 @@
        }
 
        public CorrelationKey getValue() {
-               return _correlationKey;
+               return new CorrelationKey(_correlationKey);
        }
 
        public void setValue(QName[] names, CorrelationKey values) {
-               _correlationKey = values;
+               _correlationKey = values.toCanonicalString();
            for (int m = 0; m < names.length; m++) {
                _props.put(names[m], values.getValues()[m]);
         }
Index: dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java
===================================================================
--- dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java    
(revision 496886)
+++ dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java    
(working copy)
@@ -28,10 +28,89 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+<<<<<<< .mine
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EntityManager;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+import javax.persistence.Query;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+
+=======
+>>>>>>> .r496886
 @Entity
 @Table(name="ODE_PROCESS")
[EMAIL PROTECTED]({
+    @NamedQuery(name="InstanceById", query="SELECT i FROM 
ProcessInstanceDAOImpl as i WHERE i.instanceId = :iid"),
+    @NamedQuery(name="InstanceByCKey", query="SELECT cs._scope._instance FROM 
CorrelationSetDAOImpl as cs WHERE cs._correlationKey = :ckey")
+})
 public class ProcessDAOImpl implements ProcessDAO {
+<<<<<<< .mine
+       
+       @Id @Column(name="PROCESS_ID") 
+       private String _id;
+    
+       @Basic @Column(name="NUMBER_OF_INSTANCES") private int _numInstances;
+       @Basic @Column(name="PROCESS_TYPE") private String _processType;
+       @Basic @Column(name="GUID") private String _guid;
+       @Version @Column(name="VERSION") private int _version;
+       
 
+    @PersistenceContext private EntityManager _em;
+    
+       @OneToMany(fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+       private Collection<CorrelatorDAOImpl> _correlators = new 
ArrayList<CorrelatorDAOImpl>();
+       @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
+       @Column(name="CONNECTION_ID")
+       private BPELDAOConnectionImpl _connection;
+       
+       public ProcessDAOImpl() {}
+       public ProcessDAOImpl(QName pid, QName type, String guid, 
BPELDAOConnectionImpl connection) {
+        _id = pid.toString();
+               _processType = type.toString();
+               _connection = connection;
+               _guid = guid;
+       }
+       
+       public void addCorrelator(String correlator) {
+               CorrelatorDAOImpl corr = new CorrelatorDAOImpl(correlator);
+               
+               _correlators.add(corr);
+       }
+=======
+>>>>>>> .r496886
+
+<<<<<<< .mine
+       public ProcessInstanceDAO createInstance(
+                       CorrelatorDAO instantiatingCorrelator) {
+               ProcessInstanceDAOImpl inst = new 
ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, 
this,_connection);
+               _connection.getEntityManager().persist(inst);
+               _numInstances++;
+               
+               return inst;
+       }
+=======
     @Id @Column(name="PROCESS_ID")
     @GeneratedValue(strategy=GenerationType.AUTO)
     private Long _id;
@@ -40,6 +119,7 @@
     @Basic @Column(name="PROCESS_TYPE") private QName _processType;
     @Basic @Column(name="GUID") private String _guid;
     @Version @Column(name="VERSION") private int _version;
+>>>>>>> .r496886
 
     
@OneToMany(targetEntity=ProcessInstanceDAOImpl.class,mappedBy="_process",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
     private Collection<ProcessInstanceDAO> _instances = new 
ArrayList<ProcessInstanceDAO>();
@@ -50,6 +130,14 @@
     @Column(name="CONNECTION_ID")
     private BPELDAOConnectionImpl _connection;
 
+<<<<<<< .mine
+       @SuppressWarnings("unchecked")
+    public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckey) {
+               Query qry = _em.createNamedQuery("InstanceByCKey");
+        qry.setParameter("ckey", ckey.toCanonicalString());
+        return qry.getResultList();
+       }
+=======
     public ProcessDAOImpl() {}
     public ProcessDAOImpl(QName key, QName type, String guid, 
BPELDAOConnectionImpl connection, int version) {
         _processKey = key;
@@ -58,12 +146,19 @@
         _guid = guid;
         _version = version;
     }
+>>>>>>> .r496886
 
     public void addCorrelator(String correlator) {
         CorrelatorDAOImpl corr = new CorrelatorDAOImpl(correlator);
 
+<<<<<<< .mine
+       public ProcessInstanceDAO getInstance(Long iid) {
+               return _connection.getInstance(iid);
+       }
+=======
         _correlators.add(corr);
     }
+>>>>>>> .r496886
 
     public ProcessInstanceDAO createInstance(
             CorrelatorDAO instantiatingCorrelator) {
@@ -72,16 +167,30 @@
         _instances.add(inst);
         _numInstances++;
 
+<<<<<<< .mine
+       public QName getProcessId() {
+               return QName.valueOf(_id);
+       }
+=======
         return inst;
     }
+>>>>>>> .r496886
 
+<<<<<<< .mine
+       public QName getType() {
+               return QName.valueOf(_processType);
+       }
+=======
     public void delete() {
         _connection.removeProcess(this);
     }
+>>>>>>> .r496886
 
     public Collection<ProcessInstanceDAO> findInstance(CorrelationKey cckey) {
         Collection<ProcessInstanceDAO> ret = new 
ArrayList<ProcessInstanceDAO>();
 
+<<<<<<< .mine
+=======
         for (ProcessInstanceDAO pi : _instances) {
             scope_block:for (ScopeDAO s : pi.getScopes()) {
                 for (CorrelationSetDAO c : s.getCorrelationSets()) {
@@ -93,6 +202,7 @@
         return ret;
     }
 
+>>>>>>> .r496886
     public CorrelatorDAO getCorrelator(String correlatorId) {
         for ( CorrelatorDAO c : _correlators ) {
             if ( c.getCorrelatorId().equals(correlatorId) ) return c;
Index: dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
===================================================================
--- dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java     
(revision 496886)
+++ dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java     
(working copy)
@@ -19,33 +19,33 @@
 
 package org.apache.ode.dao.jpa;
 
-import org.apache.ode.bpel.common.BpelEventFilter;
-import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.common.ProcessFilter;
-import org.apache.ode.bpel.dao.*;
-import org.apache.ode.bpel.evt.BpelEvent;
-import org.apache.ode.bpel.evt.ScopeEvent;
-
-import javax.persistence.*;
-import javax.xml.namespace.QName;
 import java.sql.Timestamp;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
[EMAIL PROTECTED]
[EMAIL PROTECTED](name="ODE_ROOT")
-public class BPELDAOConnectionImpl implements BpelDAOConnection {
+import javax.persistence.EntityManager;
+import javax.xml.namespace.QName;
 
-    @Transient private EntityManager _em;
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
 
-    @Id @Column(name="ROOT_ID")
-    private Long _id;
+public class BPELDAOConnectionImpl implements BpelDAOConnection {
+       
+       EntityManager _em;
 
-    
@OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
-    private Collection<ProcessDAOImpl> _processes = new 
ArrayList<ProcessDAOImpl>();
 
+<<<<<<< .mine
+    
+    public BPELDAOConnectionImpl(EntityManager em) {
+=======
     
@OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
     private Collection<ProcessInstanceDAOImpl> _instances = new 
ArrayList<ProcessInstanceDAOImpl>();
 
@@ -57,9 +57,11 @@
 
     public BPELDAOConnectionImpl(EntityManager em) {
         _id = 0L;
+>>>>>>> .r496886
         _em = em;
     }
 
+
     public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
                                           BpelEventFilter efilter) {
         // TODO Auto-generated method stub
@@ -70,12 +72,22 @@
         //return null;
     }
 
+       public ProcessDAO createProcess(QName pid, QName type, String guid) {
+               ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,this);
+               _em.persist(ret);
+               return ret;
+       }
+
     public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter,
                                              BpelEventFilter efilter) {
         // TODO Auto-generated method stub
         //return null;
         throw new UnsupportedOperationException();
     }
+       
+       public ProcessInstanceDAO getInstance(Long iid) {
+        return _em.find(ProcessInstanceDAOImpl.class, iid);
+       }
 
     public void close() {
         _em = null;
@@ -83,11 +95,14 @@
     }
 
     public MessageExchangeDAO createMessageExchange(char dir) {
-        MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir,this);
-        _messageEx.add(ret);
+        MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir);
+        _em.persist(ret);
         return ret;
     }
 
+<<<<<<< .mine
+
+=======
     public ProcessDAO createProcess(QName pid, QName type, String guid, int 
version) {
         ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,this,version);
 
@@ -138,6 +153,7 @@
         return null;
     }
 
+>>>>>>> .r496886
     public void insertBpelEvent(BpelEvent event, ProcessDAO process, 
ProcessInstanceDAO instance) {
         EventDAOImpl eventDao = new EventDAOImpl();
         eventDao.setTstamp(new Timestamp(System.currentTimeMillis()));
@@ -151,39 +167,52 @@
             eventDao.setScopeId(((ScopeEvent) event).getScopeId());
         eventDao.setEvent(event);
         _em.persist(eventDao);
-    }
-
+       }
+
+       @SuppressWarnings("unchecked")
     public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter 
criteria) {
-        // TODO: Implement me
-        return new ArrayList<ProcessInstanceDAO>(_instances);
-    }
+        return _em.createQuery("select x from ProcessInstanceDAOImpl as 
x").getResultList();
+       }
 
-    public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
-        // TODO: Implement me
-        return new ArrayList<ProcessInstanceDAO>(_instances);
-    }
+   
+       public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
+           return instanceQuery(new InstanceFilter(expression));
+       }
 
-    public Collection<ProcessDAO> processQuery(ProcessFilter criteria) {
-        // TODO: Implement me
-        return new ArrayList<ProcessDAO>(_processes);
+       EntityManager getEntityManager() {
+               return _em;
+       }
+       
+       public void setEntityManger(EntityManager em) {
+               _em = em;
+       }
+       
+       void removeProcess(ProcessDAOImpl p) {
+               
+               if ( _em != null ) {
+                       _em.remove(p);
+                       _em.flush();
+               }
+               
+       }
+
+    public MessageExchangeDAO getMessageExchange(String mexid) {
+        return _em.find(MessageExchangeDAOImpl.class, mexid);
     }
+
 
+<<<<<<< .mine
+    public ProcessDAO getProcess(QName processId) {
+        return _em.find(ProcessDAOImpl.class, processId.toString());
+=======
     public EntityManager getEntityManager() {
         return _em;
+>>>>>>> .r496886
     }
 
-    public void setEntityManger(EntityManager em) {
-        _em = em;
+    public ScopeDAO getScope(Long siidl) {
+        return _em.find(ScopeDAOImpl.class, siidl);
     }
 
-    void removeProcess(ProcessDAOImpl p) {
-        _processes.remove(p);
 
-        if ( _em != null ) {
-            _em.remove(p);
-            _em.flush();
-        }
-
-    }
-
 }
Index: dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
===================================================================
--- dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java    
(revision 496886)
+++ dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java    
(working copy)
@@ -69,7 +69,6 @@
        public ProcessInstanceDAOImpl(CorrelatorDAOImpl correlator, 
ProcessDAOImpl process, BPELDAOConnectionImpl connection) {
                _instantiatingCorrelator = correlator;
                _connection = connection;
-               _connection.addInstance(this);
                _process = process;
        }
        
@@ -84,7 +83,7 @@
 
        public ScopeDAO createScope(ScopeDAO parentScope, String name,
                        int scopeModelId) {
-               ScopeDAOImpl ret = new 
ScopeDAOImpl((ScopeDAOImpl)parentScope,name,scopeModelId,this,_connection);
+               ScopeDAOImpl ret = new 
ScopeDAOImpl((ScopeDAOImpl)parentScope,name,scopeModelId,this);
         ret.setState(ScopeStateEnum.ACTIVE);
 
         _scopes.add(ret);
@@ -119,7 +118,6 @@
            // make sure we have completed.
            assert (ProcessState.isFinished(this.getState()));
            // let our process know that we've done our work.
-           this.getProcess().instanceCompleted(this);
        }
 
        public long genMonotonic() {
Index: dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java
===================================================================
--- dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java    
(revision 496886)
+++ dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java    
(working copy)
@@ -95,14 +95,11 @@
        @Column(name="RESPONSE_MESSAGE_ID")
        private MessageDAOImpl _response;
        @Version @Column(name="VERSION") private long _version;
-       @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
-       @Column(name="CONNECTION_ID")
-       private BPELDAOConnectionImpl _connection;
-       
+               
        public MessageExchangeDAOImpl() {}
-       public MessageExchangeDAOImpl(char direction, BPELDAOConnectionImpl 
connection){
+    
+       public MessageExchangeDAOImpl(char direction){
                _direction = direction;
-               _connection = connection;
                _id = new UUID().toString();
        }
        

Reply via email to