You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2007/01/08 19:07:43 UTC
svn commit: r494135 - in /incubator/ode/trunk:
dao-jpa-ojpa-derby/src/main/descriptors/
dao-jpa-ojpa-derby/src/test/resources/META-INF/
dao-jpa-ojpa/src/main/resources/META-INF/
dao-jpa/src/main/java/org/apache/ode/dao/jpa/
Author: mriou
Date: Mon Jan 8 10:07:43 2007
New Revision: 494135
URL: http://svn.apache.org/viewvc?view=rev&rev=494135
Log:
Added events persistence for JPA.
Added:
incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java
Modified:
incubator/ode/trunk/dao-jpa-ojpa-derby/src/main/descriptors/persistence.derby.xml
incubator/ode/trunk/dao-jpa-ojpa-derby/src/test/resources/META-INF/persistence.xml
incubator/ode/trunk/dao-jpa-ojpa/src/main/resources/META-INF/persistence.xml
incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
Modified: incubator/ode/trunk/dao-jpa-ojpa-derby/src/main/descriptors/persistence.derby.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa-ojpa-derby/src/main/descriptors/persistence.derby.xml?view=diff&rev=494135&r1=494134&r2=494135
==============================================================================
--- incubator/ode/trunk/dao-jpa-ojpa-derby/src/main/descriptors/persistence.derby.xml (original)
+++ incubator/ode/trunk/dao-jpa-ojpa-derby/src/main/descriptors/persistence.derby.xml Mon Jan 8 10:07:43 2007
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
- <persistence-unit name="ode-unit-test-embedded">
+ <persistence-unit name="ode-unit-test-embedded">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class>
<class>org.apache.ode.dao.jpa.BPELDAOConnectionImpl</class>
<class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
<class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
<class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
<class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
<class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
@@ -18,7 +19,7 @@
<class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
<class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
<class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
-
+
<properties>
<!-- Properties for an embedded Derby connection -->
<property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
@@ -27,7 +28,7 @@
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.ConnectionProperties"
- value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
+ value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
</properties>
</persistence-unit>
Modified: incubator/ode/trunk/dao-jpa-ojpa-derby/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa-ojpa-derby/src/test/resources/META-INF/persistence.xml?view=diff&rev=494135&r1=494134&r2=494135
==============================================================================
--- incubator/ode/trunk/dao-jpa-ojpa-derby/src/test/resources/META-INF/persistence.xml (original)
+++ incubator/ode/trunk/dao-jpa-ojpa-derby/src/test/resources/META-INF/persistence.xml Mon Jan 8 10:07:43 2007
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
- <persistence-unit name="ode-unit-test-embedded">
+ <persistence-unit name="ode-unit-test-embedded">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class>
<class>org.apache.ode.dao.jpa.BPELDAOConnectionImpl</class>
<class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
<class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
<class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
<class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
<class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
@@ -30,7 +31,7 @@
<property name="openjpa.ConnectionURL" value="jdbc:derby:target/database/derby/ode-test-db;create=false"/>
<property name="openjpa.ConnectionUserName" value="SA"/>
<property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.DerbyDictionary"/>
-
+
<!-- Use this property to generate DDL at runtime
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
-->
Modified: incubator/ode/trunk/dao-jpa-ojpa/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa-ojpa/src/main/resources/META-INF/persistence.xml?view=diff&rev=494135&r1=494134&r2=494135
==============================================================================
--- incubator/ode/trunk/dao-jpa-ojpa/src/main/resources/META-INF/persistence.xml (original)
+++ incubator/ode/trunk/dao-jpa-ojpa/src/main/resources/META-INF/persistence.xml Mon Jan 8 10:07:43 2007
@@ -12,6 +12,7 @@
<class>org.apache.ode.dao.jpa.BPELDAOConnectionImpl</class>
<class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
<class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
<class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
<class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
<class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
Modified: incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java?view=diff&rev=494135&r1=494134&r2=494135
==============================================================================
--- incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java (original)
+++ incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java Mon Jan 8 10:07:43 2007
@@ -24,9 +24,11 @@
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;
@@ -35,149 +37,155 @@
@Entity
@Table(name="ODE_ROOT")
public class BPELDAOConnectionImpl implements BpelDAOConnection {
-
- @Transient private EntityManager _em;
- @Id @Column(name="ROOT_ID")
- private Long _id;
-
- @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
- private Collection<ProcessDAOImpl> _processes = new ArrayList<ProcessDAOImpl>();
-
- @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
- private Collection<ProcessInstanceDAOImpl> _instances = new ArrayList<ProcessInstanceDAOImpl>();
-
- @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
- private Collection<MessageExchangeDAOImpl> _messageEx = new ArrayList<MessageExchangeDAOImpl>();
-
- @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
- private Collection<ScopeDAOImpl> _scopes = new ArrayList<ScopeDAOImpl>();
-
- public BPELDAOConnectionImpl() {}
- public BPELDAOConnectionImpl(Long id, EntityManager em) {
- _id = id;
- _em = em;
- }
-
- public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
- BpelEventFilter efilter) {
- // TODO Auto-generated method stub
- //return null;
- throw new UnsupportedOperationException();
- //System.out.println(ifilter.toString());
- //System.out.println(efilter.toString());
- //return null;
- }
-
- public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter,
- BpelEventFilter efilter) {
- // TODO Auto-generated method stub
- //return null;
- throw new UnsupportedOperationException();
- }
-
- public void close() {
- _em = null;
-
- }
-
- public MessageExchangeDAO createMessageExchange(char dir) {
- MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir,this);
- _messageEx.add(ret);
- return ret;
- }
-
- public ProcessDAO createProcess(QName pid, QName type, String guid) {
- ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,this);
-
- _processes.add(ret);
- return ret;
- }
-
- void addInstance(ProcessInstanceDAOImpl inst) {
- _instances.add(inst);
- }
- void addScope(ScopeDAOImpl scope) {
- _scopes.add(scope);
- }
- public Long getID() {
- return _id;
- }
- public void setID(Long id) {
- _id = id;
- }
-
- public ProcessInstanceDAO getInstance(Long iid) {
- // TODO: may need a map or DB lookup here for performance
- for (ProcessInstanceDAO inst : _instances) {
- if (inst.getInstanceId().equals(iid) ) return inst;
- }
- return null;
- }
-
- public MessageExchangeDAO getMessageExchange(String mexid) {
- // TODO: may need a map or DB lookup here for performance
- for ( MessageExchangeDAOImpl mex : _messageEx ) {
- if ( mex.getMessageExchangeId().equals(mexid)) return mex;
- }
- return null;
- }
-
- public ProcessDAO getProcess(QName processId) {
- for ( ProcessDAOImpl p : _processes){
- if ( p.getProcessId().equals(processId)) return p;
- }
- return null;
- }
-
- public ScopeDAO getScope(Long siidl) {
- // TODO: May need a map or DB lookup here for performance
- for ( ScopeDAOImpl s : _scopes ) {
- if ( s.getScopeInstanceId().equals(siidl) ) return s;
- }
- return null;
- }
-
- public void insertBpelEvent(BpelEvent event, ProcessDAO process,
- ProcessInstanceDAO instance) {
- // TODO Auto-generated method stub
- //throw new UnsupportedOperationException();
- //System.out.println(event.toString());
- //System.out.println(process.toString());
- //System.out.println(instance.toString());
- }
+ @Transient private EntityManager _em;
- public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria) {
+ @Id @Column(name="ROOT_ID")
+ private Long _id;
+
+ @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
+ private Collection<ProcessDAOImpl> _processes = new ArrayList<ProcessDAOImpl>();
+
+ @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
+ private Collection<ProcessInstanceDAOImpl> _instances = new ArrayList<ProcessInstanceDAOImpl>();
+
+ @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
+ private Collection<MessageExchangeDAOImpl> _messageEx = new ArrayList<MessageExchangeDAOImpl>();
+
+ @OneToMany(fetch=FetchType.LAZY,mappedBy="_connection",cascade={CascadeType.ALL})
+ private Collection<ScopeDAOImpl> _scopes = new ArrayList<ScopeDAOImpl>();
+
+ public BPELDAOConnectionImpl() {}
+ public BPELDAOConnectionImpl(Long id, EntityManager em) {
+ _id = id;
+ _em = em;
+ }
+
+ public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
+ BpelEventFilter efilter) {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new UnsupportedOperationException();
+ //System.out.println(ifilter.toString());
+ //System.out.println(efilter.toString());
+ //return null;
+ }
+
+ public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter,
+ BpelEventFilter efilter) {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new UnsupportedOperationException();
+ }
+
+ public void close() {
+ _em = null;
+
+ }
+
+ public MessageExchangeDAO createMessageExchange(char dir) {
+ MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir,this);
+ _messageEx.add(ret);
+ return ret;
+ }
+
+ public ProcessDAO createProcess(QName pid, QName type, String guid) {
+ ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,this);
+
+ _processes.add(ret);
+ return ret;
+ }
+
+ void addInstance(ProcessInstanceDAOImpl inst) {
+ _instances.add(inst);
+ }
+ void addScope(ScopeDAOImpl scope) {
+ _scopes.add(scope);
+ }
+ public Long getID() {
+ return _id;
+ }
+ public void setID(Long id) {
+ _id = id;
+ }
+
+ public ProcessInstanceDAO getInstance(Long iid) {
+ // TODO: may need a map or DB lookup here for performance
+ for (ProcessInstanceDAO inst : _instances) {
+ if (inst.getInstanceId().equals(iid) ) return inst;
+ }
+ return null;
+ }
+
+ public MessageExchangeDAO getMessageExchange(String mexid) {
+ // TODO: may need a map or DB lookup here for performance
+ for ( MessageExchangeDAOImpl mex : _messageEx ) {
+ if ( mex.getMessageExchangeId().equals(mexid)) return mex;
+ }
+ return null;
+ }
+
+ public ProcessDAO getProcess(QName processId) {
+ for ( ProcessDAOImpl p : _processes){
+ if ( p.getProcessId().equals(processId)) return p;
+ }
+ return null;
+ }
+
+ public ScopeDAO getScope(Long siidl) {
+ // TODO: May need a map or DB lookup here for performance
+ for ( ScopeDAOImpl s : _scopes ) {
+ if ( s.getScopeInstanceId().equals(siidl) ) return s;
+ }
+ return null;
+ }
+
+ public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
+ EventDAOImpl eventDao = new EventDAOImpl();
+ eventDao.setTstamp(new Timestamp(System.currentTimeMillis()));
+ eventDao.setType(BpelEvent.eventName(event));
+ eventDao.setDetail(event.toString());
+ if (process != null)
+ eventDao.setProcess((ProcessDAOImpl) process);
+ if (instance != null)
+ eventDao.setInstance((ProcessInstanceDAOImpl) instance);
+ if (event instanceof ScopeEvent)
+ eventDao.setScopeId(((ScopeEvent) event).getScopeId());
+ eventDao.setEvent(event);
+ _em.persist(eventDao);
+ }
+
+ public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria) {
// TODO: Implement me
return new ArrayList<ProcessInstanceDAO>(_instances);
- }
+ }
- public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
+ public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
// TODO: Implement me
return new ArrayList<ProcessInstanceDAO>(_instances);
- }
+ }
- public Collection<ProcessDAO> processQuery(ProcessFilter criteria) {
+ 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) {
- _processes.remove(p);
-
- if ( _em != null ) {
- _em.remove(p);
- _em.flush();
- }
-
- }
+ }
+
+ EntityManager getEntityManager() {
+ return _em;
+ }
+
+ public void setEntityManger(EntityManager em) {
+ _em = em;
+ }
+
+ void removeProcess(ProcessDAOImpl p) {
+ _processes.remove(p);
+
+ if ( _em != null ) {
+ _em.remove(p);
+ _em.flush();
+ }
+
+ }
}
Added: incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java?view=auto&rev=494135
==============================================================================
--- incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java (added)
+++ incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/EventDAOImpl.java Mon Jan 8 10:07:43 2007
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa;
+
+import org.apache.ode.bpel.evt.BpelEvent;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_EVENT")
+public class EventDAOImpl {
+
+ @Id @Column(name="EVENT_ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ private Long _id;
+ @Basic @Column(name="TSTAMP")
+ private Timestamp _tstamp;
+ @Basic @Column(name="TYPE")
+ private String _type;
+ @Basic @Column(name="DETAIL")
+ private String _detail;
+
+ /** Scope identifier, possibly null. */
+ @Basic @Column(name="SCOPE_ID")
+ private Long _scopeId;
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @Column(name="PROCESS_ID")
+ private ProcessDAOImpl _process;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @Column(name="INSTANCE_ID")
+ private ProcessInstanceDAOImpl _instance;
+ @Lob @Column(name="DATA")
+ private BpelEvent _event;
+
+ public BpelEvent getEvent() {
+ return _event;
+ }
+
+ public void setEvent(BpelEvent event) {
+ _event = event;
+ }
+
+ public String getDetail() {
+ return _detail;
+ }
+
+ public void setDetail(String detail) {
+ _detail = detail;
+ }
+
+ public Long getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ _id = id;
+ }
+
+ public ProcessInstanceDAOImpl getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(ProcessInstanceDAOImpl instance) {
+ _instance = instance;
+ }
+
+ public ProcessDAOImpl getProcess() {
+ return _process;
+ }
+
+ public void setProcess(ProcessDAOImpl process) {
+ _process = process;
+ }
+
+ public Timestamp getTstamp() {
+ return _tstamp;
+ }
+
+ public void setTstamp(Timestamp tstamp) {
+ _tstamp = tstamp;
+ }
+
+ public String getType() {
+ return _type;
+ }
+
+ public void setType(String type) {
+ _type = type;
+ }
+
+ public Long getScopeId() {
+ return _scopeId;
+ }
+
+ public void setScopeId(Long scopeId) {
+ _scopeId = scopeId;
+ }
+}