You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by je...@apache.org on 2010/08/18 06:12:59 UTC
svn commit: r986561 [11/13] - in /ode/trunk: ./ axis2-war/
axis2-war/src/main/assembly/ axis2-war/src/test/java/org/apache/ode/axis2/
axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/
axis2-war/src/test/java/org/apache/ode/bpel/dao/ axis2-w...
Added: ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-postgres.sql Wed Aug 18 04:12:49 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+--
+-- Apache Derby scripts by Maciej Szefler.
+--
+--
+
+CREATE TABLE ODE_JOB (
+ jobid CHAR(64) NOT NULL DEFAULT '',
+ ts BIGINT NOT NULL DEFAULT 0,
+ nodeid char(64),
+ scheduled int NOT NULL DEFAULT 0,
+ transacted int NOT NULL DEFAULT 0,
+
+ instanceId BIGINT,
+ mexId varchar(255),
+ processId varchar(255),
+ type varchar(255),
+ channel varchar(255),
+ correlatorId varchar(255),
+ correlationKeySet varchar(255),
+ retryCount int,
+ inMem int,
+ detailsExt bytea,
+
+ PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ODE_JOB(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ODE_JOB(nodeid);
+
+
Added: ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-sqlserver.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-sqlserver.sql?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-sqlserver.sql (added)
+++ ode/trunk/dao-jpa-hibernate/src/main/scripts/simplesched-sqlserver.sql Wed Aug 18 04:12:49 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+--
+-- Apache Derby scripts by Maciej Szefler.
+--
+--
+
+CREATE TABLE ODE_JOB (
+ jobid CHAR(64) NOT NULL DEFAULT '',
+ ts BIGINT NOT NULL DEFAULT 0,
+ nodeid char(64),
+ scheduled int NOT NULL DEFAULT 0,
+ transacted int NOT NULL DEFAULT 0,
+
+ instanceId BIGINT,
+ mexId varchar(255),
+ processId varchar(255),
+ type varchar(255),
+ channel varchar(255),
+ correlatorId varchar(255),
+ correlationKeySet varchar(255),
+ retryCount int,
+ inMem int,
+ detailsExt image null,
+
+ PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ODE_JOB(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ODE_JOB(nodeid);
+
+
Modified: ode/trunk/dao-jpa-ojpa-derby/pom.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa-derby/pom.xml?rev=986561&r1=986560&r2=986561&view=diff
==============================================================================
--- ode/trunk/dao-jpa-ojpa-derby/pom.xml (original)
+++ ode/trunk/dao-jpa-ojpa-derby/pom.xml Wed Aug 18 04:12:49 2010
@@ -111,8 +111,8 @@
<artifactId>geronimo-ejb_2.1_spec</artifactId>
</dependency>
<dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
@@ -205,7 +205,7 @@
<configuration>
<tasks>
<property name="ode.version" value="${project.version}"/>
- <ant antfile="build.xml" target="zip-derby-db" />
+ <ant antfile="build.xml" target="zip-derby-db" />
</tasks>
</configuration>
</execution>
Added: ode/trunk/dao-jpa-ojpa/pom.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/pom.xml?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/pom.xml (added)
+++ ode/trunk/dao-jpa-ojpa/pom.xml Wed Aug 18 04:12:49 2010
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+-->
+<project xmlns:pom="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa</artifactId>
+ <name>ODE :: JPA OpenJPA DAO Impl</name>
+
+ <parent>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode</artifactId>
+ <version>1.3.5-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-schemas</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-epr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa</artifactId>
+ <classifier>openjpa</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.serp</groupId>
+ <artifactId>serp</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.derby.xml Wed Aug 18 04:12:49 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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.
+ -->
+<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">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</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>
+ <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+
+ <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+ <properties>
+ <!-- Properties for an embedded Derby connection -->
+ <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+ <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.DerbyDictionary"/>
+ <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+ <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"/>
+
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.mysql.xml Wed Aug 18 04:12:49 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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.
+ -->
+<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">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</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>
+ <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+
+ <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+ <properties>
+ <!-- Properties for an embedded Derby connection -->
+ <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+ <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.MySQLDictionary"/>
+ <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+ <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"/>
+
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.oracle.xml Wed Aug 18 04:12:49 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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.
+ -->
+<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">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</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>
+ <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+
+ <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+ <properties>
+ <!-- Properties for an embedded Derby connection -->
+ <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+ <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.OracleDictionary"/>
+ <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+ <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"/>
+
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/descriptors/persistence.postgres.xml Wed Aug 18 04:12:49 2010
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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.
+ -->
+<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">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</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>
+ <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ResourceRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.ContextValueDAOImpl</class>
+
+ <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class>
+
+ <properties>
+ <!-- Properties for an embedded Derby connection -->
+ <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
+ <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.PostgresDictionary"/>
+ <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time -->
+ <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"/>
+
+ </properties>
+ </persistence-unit>
+</persistence>
+
Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/BpelDAOConnectionFactoryImpl.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,133 @@
+/*
+ * 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.openjpa;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.BpelDAOConnectionFactory;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.ode.dao.jpa.bpel.BpelDAOConnectionImpl;
+import org.apache.ode.il.config.OdeConfigProperties;
+
+/**
+
+ */
+public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactory {
+
+ static final Log __log = LogFactory.getLog(BpelDAOConnectionFactoryImpl.class);
+ static Map _defaultProperties = new HashMap();
+ static JpaOperator _operator = new JpaOperatorImpl();
+ protected EntityManagerFactory _emf;
+ protected DataSource _ds;
+ protected TransactionManager _txm;
+
+ static {
+ _defaultProperties.put("javax.persistence.provider", "org.apache.openjpa.persistence.PersistenceProviderImpl");
+ _defaultProperties.put("openjpa.Log", "log4j");
+ //This was previously set to fault but caused some issues with in memory CorrelatorDAO rout finds.
+ _defaultProperties.put("openjpa.FlushBeforeQueries", "true");
+ _defaultProperties.put("openjpa.FetchBatchSize", 1000);
+
+ // _defaultProperties.put("openjpa.Log", "DefaultLevel=TRACE");
+ }
+
+ public void init(Properties odeConfig, TransactionManager mgr, Object env) {
+ _txm = mgr;
+ _ds = (DataSource) env;
+ Map emfProperties = buildConfig(OdeConfigProperties.PROP_DAOCF + ".", odeConfig, _txm, _ds);
+ _emf = Persistence.createEntityManagerFactory("ode-bpel", emfProperties);
+ }
+
+ public BpelDAOConnection getConnection() {
+ final ThreadLocal<BpelDAOConnectionImpl> currentConnection = BpelDAOConnectionImpl.getThreadLocal();
+ BpelDAOConnectionImpl conn = (BpelDAOConnectionImpl) currentConnection.get();
+ if (conn != null && !conn.isClosed()) {
+ return conn;
+ } else {
+ EntityManager em = _emf.createEntityManager();
+ conn = createBPELDAOConnection(em, _txm, _operator);
+ currentConnection.set(conn);
+ return conn;
+ }
+ }
+
+ protected BpelDAOConnectionImpl createBPELDAOConnection(EntityManager em, TransactionManager mgr, JpaOperator operator) {
+ return new BpelDAOConnectionImpl(em, mgr, operator);
+ }
+
+ public void shutdown() {
+ _emf.close();
+ }
+
+ static Map buildConfig(String prefix, Properties odeConfig, TransactionManager mgr, DataSource ds) {
+ Map props = new HashMap(_defaultProperties);
+ if (mgr != null) {
+ props.put("openjpa.TransactionMode","managed");
+ /* The following was originally set to managed but rollback tests failed.
+ * There is no code in ODE to automatically enlist DataSource s in
+ * global transactions
+ */
+ props.put("openjpa.ConnectionFactoryMode", "local");
+ props.put("openjpa.jdbc.TransactionIsolation", "read-committed");
+ props.put("openjpa.ManagedRuntime", new JpaTxMgrProvider(mgr));
+ props.put("javax.persistence.transactionType", "JTA");
+ } else {
+ props.put("javax.persistence.transactionType", "RESOURCE_LOCAL");
+ }
+ if (ds != null) {
+ props.put("openjpa.ConnectionFactory", ds);
+ }
+
+ //props.put("openjpa.jdbc.DBDictionary", dictionary);
+
+ if (Boolean.valueOf(odeConfig.getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_CREATE, "true"))) {
+ props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(SchemaAction=drop,SchemaAction=add,ForeignKeys=true)");
+ }
+
+ addEntries(prefix, odeConfig, props);
+
+ return props;
+ }
+
+ public static void addEntries(String prefix, Properties odeConfig, Map props) {
+ if (odeConfig != null) {
+ for (Map.Entry me : odeConfig.entrySet()) {
+ String key = (String) me.getKey();
+ if (key.startsWith(prefix)) {
+ String jpaKey = key.substring(prefix.length() - 1);
+ String val = (String) me.getValue();
+ if (val == null || val.trim().length() == 0) {
+ props.remove(jpaKey);
+ } else {
+ props.put(jpaKey, me.getValue());
+ }
+ }
+ }
+ }
+ }
+}
Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/ConfStoreDAOConnectionFactoryImpl.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.openjpa;
+
+import java.util.Map;
+import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import org.apache.ode.dao.jpa.store.ConfStoreDAOConnectionImpl;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.dao.store.ConfStoreDAOConnection;
+import org.apache.ode.dao.store.ConfStoreDAOConnectionFactory;
+import static org.apache.ode.dao.jpa.openjpa.BpelDAOConnectionFactoryImpl._operator;
+import static org.apache.ode.dao.jpa.openjpa.BpelDAOConnectionFactoryImpl.buildConfig;
+
+public class ConfStoreDAOConnectionFactoryImpl implements ConfStoreDAOConnectionFactory {
+
+ EntityManagerFactory _emf;
+ TransactionManager _txm;
+ DataSource _ds;
+
+ public void init(Properties odeConfig, TransactionManager txm, Object env) {
+ _txm=txm;
+ _ds = (DataSource) env;
+ Map emfProperties = buildConfig(OdeConfigProperties.PROP_DAOCF_STORE + ".", odeConfig, _txm, _ds);
+ _emf = Persistence.createEntityManagerFactory("ode-store", emfProperties);
+
+ }
+
+ public ConfStoreDAOConnection getConnection() {
+ final ThreadLocal<ConfStoreDAOConnectionImpl> currentConnection = ConfStoreDAOConnectionImpl.getThreadLocal();
+ ConfStoreDAOConnectionImpl conn = (ConfStoreDAOConnectionImpl) currentConnection.get();
+ if (conn != null && !conn.isClosed()) {
+ return conn;
+ } else {
+ EntityManager em = _emf.createEntityManager();
+ conn = new ConfStoreDAOConnectionImpl(em, _txm, _operator);
+ currentConnection.set(conn);
+ return conn;
+ }
+ }
+
+ public void shutdown() {
+ _emf.close();
+ }
+}
Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaOperatorImpl.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,64 @@
+/*
+ * 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.openjpa;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+/**
+ *
+ *
+ * @author Matthieu Riou <mriou at apache dot org>
+ * @author Jeff Yu
+ */
+public class JpaOperatorImpl implements JpaOperator {
+ private static final Log __log = LogFactory.getLog(JpaOperatorImpl.class);
+
+ public <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName) {
+ if( query instanceof OpenJPAQuery ) {
+ OpenJPAQuery openJpaQuery = (OpenJPAQuery)query;
+ int batchSize = openJpaQuery.getFetchPlan().getFetchBatchSize();
+ if( __log.isTraceEnabled() ) __log.trace("BATCH fetchBatchSize = " + batchSize);
+ List<T> batch = new ArrayList<T>();
+ while( ids.hasNext() ) {
+ for( int i = 0; i < batchSize && ids.hasNext(); i++ ) {
+ batch.add(ids.next());
+ }
+ if( __log.isTraceEnabled() ) __log.trace("BATCH updating " + batch.size() + " objects.");
+ query.setParameter(parameterName, batch);
+ query.executeUpdate();
+ batch.clear();
+ }
+ }
+ }
+
+ public void setBatchSize(Query query, int limit) {
+ OpenJPAQuery kq = OpenJPAPersistence.cast(query);
+ kq.getFetchPlan().setFetchBatchSize(limit);
+ }
+}
\ No newline at end of file
Added: ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/java/org/apache/ode/dao/jpa/openjpa/JpaTxMgrProvider.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.openjpa;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.openjpa.ee.ManagedRuntime;
+import org.apache.openjpa.util.GeneralException;
+
+public class JpaTxMgrProvider implements ManagedRuntime {
+ private TransactionManager _txMgr;
+
+ public JpaTxMgrProvider(TransactionManager txMgr) {
+ _txMgr = txMgr;
+ }
+
+ public TransactionManager getTransactionManager() throws Exception {
+ return _txMgr;
+ }
+
+ public void setRollbackOnly(Throwable cause) throws Exception {
+ // there is no generic support for setting the rollback cause
+ getTransactionManager().getTransaction().setRollbackOnly();
+ }
+
+ public Throwable getRollbackCause() throws Exception {
+ // there is no generic support for setting the rollback cause
+ return null;
+ }
+
+ public Object getTransactionKey() throws Exception, SystemException {
+ return _txMgr.getTransaction();
+ }
+
+ public void doNonTransactionalWork(java.lang.Runnable runnable) throws NotSupportedException {
+ TransactionManager tm = null;
+ Transaction transaction = null;
+
+ try {
+ tm = getTransactionManager();
+ transaction = tm.suspend();
+ } catch (Exception e) {
+ NotSupportedException nse =
+ new NotSupportedException(e.getMessage());
+ nse.initCause(e);
+ throw nse;
+ }
+
+ runnable.run();
+
+ try {
+ tm.resume(transaction);
+ } catch (Exception e) {
+ try {
+ transaction.setRollbackOnly();
+ }
+ catch(SystemException se2) {
+ throw new GeneralException(se2);
+ }
+ NotSupportedException nse =
+ new NotSupportedException(e.getMessage());
+ nse.initCause(e);
+ throw nse;
+ }
+ }
+}
\ No newline at end of file
Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/license-header.sql Wed Aug 18 04:12:49 2010
@@ -0,0 +1,19 @@
+--
+-- 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.
+--
+
Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-derby.sql Wed Aug 18 04:12:49 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+--
+-- Apache Derby scripts by Maciej Szefler.
+--
+--
+
+CREATE TABLE ode_job (
+ jobid CHAR(64) NOT NULL DEFAULT '',
+ ts BIGINT NOT NULL DEFAULT 0,
+ nodeid char(64),
+ scheduled int NOT NULL DEFAULT 0,
+ transacted int NOT NULL DEFAULT 0,
+
+ instanceId BIGINT,
+ mexId varchar(255),
+ processId varchar(255),
+ type varchar(255),
+ channel varchar(255),
+ correlatorId varchar(255),
+ correlationKey varchar(255),
+ retryCount int,
+ inMem int,
+ detailsExt blob(4096),
+
+ PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+
Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-mysql.sql Wed Aug 18 04:12:49 2010
@@ -0,0 +1,33 @@
+-- Apache ODE - SimpleScheduler Database Schema
+--
+-- MySQL scripts by Maciej Szefler.
+--
+--
+DROP TABLE IF EXISTS ODE_JOB;
+
+CREATE TABLE ODE_JOB (
+ jobid CHAR(64) NOT NULL DEFAULT '',
+ ts BIGINT NOT NULL DEFAULT 0,
+ nodeid char(64) NULL,
+ scheduled int NOT NULL DEFAULT 0,
+ transacted int NOT NULL DEFAULT 0,
+
+ instanceId BIGINT,
+ mexId varchar(255),
+ processId varchar(255),
+ type varchar(255),
+ channel varchar(255),
+ correlatorId varchar(255),
+ correlationKey varchar(255),
+ retryCount int,
+ inMem int,
+ detailsExt blob(4096),
+
+ PRIMARY KEY(jobid),
+ INDEX IDX_ODE_JOB_TS(ts),
+ INDEX IDX_ODE_JOB_NODEID(nodeid)
+)
+TYPE=InnoDB;
+
+COMMIT;
+
Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-oracle.sql Wed Aug 18 04:12:49 2010
@@ -0,0 +1,32 @@
+-- Apache ODE - SimpleScheduler Database Schema
+--
+-- Apache Derby scripts by Maciej Szefler.
+--
+--
+
+DROP TABLE ode_job;
+
+CREATE TABLE ode_job (
+ jobid VARCHAR(64) NOT NULL,
+ ts number(37) NOT NULL,
+ nodeid varchar(64),
+ scheduled int NOT NULL,
+ transacted int NOT NULL,
+
+ instanceId number(37),
+ mexId varchar(255),
+ processId varchar(255),
+ type varchar(255),
+ channel varchar(255),
+ correlatorId varchar(255),
+ correlationKey varchar(255),
+ retryCount int,
+ inMem int,
+ detailsExt blob,
+
+ PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+
Added: ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql (added)
+++ ode/trunk/dao-jpa-ojpa/src/main/scripts/simplesched-postgres.sql Wed Aug 18 04:12:49 2010
@@ -0,0 +1,30 @@
+-- Apache ODE - SimpleScheduler Database Schema
+--
+-- Apache Derby scripts by Maciej Szefler.
+--
+--
+
+CREATE TABLE ode_job (
+ jobid CHAR(64) NOT NULL DEFAULT '',
+ ts BIGINT NOT NULL DEFAULT 0,
+ nodeid char(64),
+ scheduled int NOT NULL DEFAULT 0,
+ transacted int NOT NULL DEFAULT 0,
+
+ instanceId BIGINT,
+ mexId varchar(255),
+ processId varchar(255),
+ type varchar(255),
+ channel varchar(255),
+ correlatorId varchar(255),
+ correlationKey varchar(255),
+ retryCount int,
+ inMem int,
+ detailsExt bytea,
+
+ PRIMARY KEY(jobid));
+
+CREATE INDEX IDX_ODE_JOB_TS ON ode_job(ts);
+CREATE INDEX IDX_ODE_JOB_NODEID ON ode_job(nodeid);
+
+
Modified: ode/trunk/dao-jpa/pom.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/pom.xml?rev=986561&r1=986560&r2=986561&view=diff
==============================================================================
--- ode/trunk/dao-jpa/pom.xml (original)
+++ ode/trunk/dao-jpa/pom.xml Wed Aug 18 04:12:49 2010
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.ode</groupId>
<artifactId>ode-dao-jpa</artifactId>
- <name>ODE :: OpenJPA DAO Impl</name>
+ <name>ODE :: JPA DAO Impl</name>
<parent>
<groupId>org.apache.ode</groupId>
@@ -98,25 +98,43 @@
</goals>
<configuration>
<tasks>
- <property name="maven.runtime.classpath" refid="maven.compile.classpath"/>
+ <copy todir="${basedir}/target/classes-openjpa">
+ <fileset dir="${basedir}/target/classes" includes="**/*"/>
+ </copy>
+ <property name="maven.compile.classpath" refid="maven.compile.classpath"/>
<path id="classpath">
- <pathelement path="${maven.runtime.classpath}"/>
- </path>
- <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="classpath"/>
- <openjpac>
- <fileset dir="${basedir}/src/main">
- <include name="**/*.java" />
- </fileset>
- <classpath>
- <pathelement location="${basedir}/target/classes"/>
- <pathelement path="${maven.runtime.classpath}"/>
- </classpath>
- </openjpac>
+ <pathelement location="${basedir}/target/classes-openjpa"/>
+ <pathelement path="${maven.compile.classpath}"/>
+ </path>
+ <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="classpath"/>
+ <openjpac directory="${basedir}/target/classes-openjpa">
+ <fileset dir="${basedir}/src/main">
+ <include name="**/*.java" />
+ </fileset>
+ <classpath refid="classpath"/>
+ </openjpac>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>openjpa-enhancer-package</id>
+ <phase>package</phase>
+ <configuration>
+ <classifier>openjpa</classifier>
+ <classesDirectory>${project.build.directory}/classes-openjpa</classesDirectory>
+ </configuration>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaConnection.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,146 @@
+/*
+ * 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 javax.persistence.EntityManager;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.DAOConnection;
+
+public class JpaConnection implements DAOConnection {
+
+ private static final Log __log = LogFactory.getLog(JpaConnection.class);
+ final protected EntityManager _em;
+ final protected TransactionManager _mgr;
+ final protected JpaTxContext _txCtx;
+ final protected JpaOperator _operator;
+
+ public JpaConnection(EntityManager em, TransactionManager mgr, JpaOperator operator) {
+ _em = em;
+ _mgr = mgr;
+ if (mgr != null) {
+ _txCtx = new JpaJtaContext();
+ } else {
+ _txCtx = new JpaNonTxContext();
+ }
+ _operator = operator;
+ }
+
+ public EntityManager getEntityManager() {
+ return _em;
+ }
+
+ public JpaOperator getJPADaoOperator() {
+ return _operator;
+ }
+
+ public void close() {
+
+ }
+
+ public boolean isClosed() {
+ return _em == null ? true : !_em.isOpen();
+ }
+
+ /** Clear out the entity manager after a commit so no stale entites are
+ * preserved across transactions and all JPA operations pull data directly from
+ * the DB.
+ *
+ */
+ public void clearOnComplete() {
+ try {
+ _mgr.getTransaction().registerSynchronization(new Synchronization() {
+
+ public void afterCompletion(int i) {
+ _em.clear();
+ if(__log.isDebugEnabled()) {
+ __log.debug("-------> clear the entity manager");
+ }
+ }
+
+ public void beforeCompletion() {
+ }
+ });
+ } catch (Exception e) {
+ __log.error("Error adding commit synchronizer", e);
+ }
+ }
+
+ protected interface JpaTxContext {
+
+ public void begin();
+
+ public void commit();
+
+ public void rollback();
+ }
+
+ class JpaJtaContext implements JpaTxContext {
+
+ /**
+ * Due to the way ODE re-uses connection on ThreadLocals it could be possible
+ * for the JPA EntityManager to not be created on the current JTA transaction
+ * and threfore it must by manually bound to the current transaction.
+ */
+ public void begin() {
+ try {
+ if (_mgr.getStatus() == Status.STATUS_ACTIVE) {
+ _em.joinTransaction();
+ clearOnComplete();
+ }
+ } catch (SystemException se) {
+ __log.error(se);
+ }
+ }
+
+ public void commit() {
+ }
+
+ public void rollback() {
+ try {
+ if (_mgr.getStatus() == Status.STATUS_ACTIVE) {
+ _mgr.setRollbackOnly();
+ }
+ } catch (Exception ex) {
+ __log.error("Unable to set rollbackOnly", ex);
+ }
+ }
+ }
+
+ class JpaNonTxContext implements JpaTxContext {
+
+ public void begin() {
+ _em.getTransaction().begin();
+ }
+
+ public void commit() {
+ _em.getTransaction().commit();
+ _em.clear();
+ }
+
+ public void rollback() {
+ _em.getTransaction().rollback();
+ _em.clear();
+ }
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/JpaOperator.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,20 @@
+package org.apache.ode.dao.jpa;
+
+import java.util.Iterator;
+
+import javax.persistence.Query;
+
+/**
+ * this is interface that will include the methods that will be used in JPA DAO,
+ * But the implementation should be different from various JPA vendor, like OpenJPA, Hibernate etc.
+ *
+ * @author Jeff Yu
+ *
+ */
+public interface JpaOperator {
+
+ public <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName);
+
+ public void setBatchSize(Query query, int limit);
+
+}
\ No newline at end of file
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ActivityRecoveryDAOImpl.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,150 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.dao.bpel.ActivityRecoveryDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import java.util.Date;
+
+
+@Entity
+@Table(name="ODE_ACTIVITY_RECOVERY")
+@NamedQueries({
+ @NamedQuery(name=ActivityRecoveryDAOImpl.DELETE_ACTIVITY_RECOVERIES_BY_IDS, query="delete from ActivityRecoveryDAOImpl as a where a._instanceId in(:ids)"),
+ @NamedQuery(name=ActivityRecoveryDAOImpl.COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES,
+ query="select r._instanceId, count(r._id) from ActivityRecoveryDAOImpl r where r._instance in(:instances) group by r._instanceId")
+})
+public class ActivityRecoveryDAOImpl implements ActivityRecoveryDAO {
+ public final static String DELETE_ACTIVITY_RECOVERIES_BY_IDS = "DELETE_ACTIVITY_RECOVERIES_BY_IDS";
+ public final static String COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES = "COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+
+ @Basic @Column(name="ACTIVITY_ID")
+ private long _activityId;
+ @Basic @Column(name="CHANNEL")
+ private String _channel;
+ @Basic @Column(name="REASON")
+ private String _reason;
+ @Basic @Column(name="DATE_TIME")
+ private Date _dateTime;
+ @Lob @Column(name="DETAILS")
+ private String _details;
+ @Basic @Column(name="ACTIONS")
+ private String _actions;
+ @Basic @Column(name="RETRIES")
+ private int _retries;
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="INSTANCE_ID", insertable=false, updatable=false, nullable=true)
+ private Long _instanceId;
+
+ // _instances is unused because this is a one-way relationship at the database level
+ @SuppressWarnings("unused")
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="INSTANCE_ID")
+ private ProcessInstanceDAOImpl _instance;
+
+
+ public ActivityRecoveryDAOImpl() {}
+ public ActivityRecoveryDAOImpl(String channel, long activityId,
+ String reason, Date dateTime, Element data, String[] actions,
+ int retries) {
+ _channel = channel;
+ _activityId = activityId;
+ _reason = reason;
+ _dateTime = dateTime;
+
+ if (data != null) _details = DOMUtils.domToString(data);
+
+ String alist = actions[0];
+ for (int i = 1; i < actions.length; ++i)
+ alist += " " + actions[i];
+ _actions = alist;
+
+ _retries = retries;
+ }
+
+ public String getActions() {
+ return _actions;
+ }
+
+ public String[] getActionsList() {
+ return getActions().split(" ");
+ }
+
+ public long getActivityId() {
+ return _activityId;
+ }
+
+ public String getChannel() {
+ return _channel;
+ }
+
+ public Date getDateTime() {
+ return _dateTime;
+ }
+
+ public Element getDetails() {
+ Element ret = null;
+ if ( _details != null ) {
+ try {
+ ret = DOMUtils.stringToDOM(_details);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return ret;
+ }
+
+ public String getReason() {
+ return _reason;
+ }
+
+ public int getRetries() {
+ return _retries;
+ }
+
+ public ProcessInstanceDAOImpl getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(ProcessInstanceDAOImpl instance) {
+ _instance = instance;
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAO.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,62 @@
+/*
+ * 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.bpel;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class BpelDAO {
+ private static final Log __log = LogFactory.getLog(BpelDAO.class);
+
+ protected BpelDAOConnectionImpl getConn() {
+ return BpelDAOConnectionImpl._connections.get();
+ }
+
+ protected EntityManager getEM() {
+ return BpelDAOConnectionImpl.getThreadLocal().get().getEntityManager();
+ }
+
+ /**
+ * javax.persistence.Query either let you query for a collection or a single
+ * value throwing an exception if nothing is found. Just a convenient shortcut
+ * for single results allowing null values
+ * @param qry query to execute
+ * @return whatever you assign it to
+ */
+ @SuppressWarnings("unchecked")
+ protected <T> T getSingleResult(Query qry) {
+ List res = qry.getResultList();
+ if (res.size() == 0) return null;
+ return (T) res.get(0);
+ }
+
+ protected <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName) {
+ BpelDAOConnectionImpl.getThreadLocal().get().getJPADaoOperator().batchUpdateByIds(ids, query, parameterName);
+ }
+}
\ No newline at end of file
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,385 @@
+/*
+ * 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.bpel;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.transaction.TransactionManager;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.Filter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.jpa.JpaConnection;
+import org.apache.ode.dao.jpa.JpaOperator;
+import org.apache.ode.utils.ISO8601DateParser;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class BpelDAOConnectionImpl extends JpaConnection implements BpelDAOConnection {
+ static final Log __log = LogFactory.getLog(BpelDAOConnectionImpl.class);
+
+ static final ThreadLocal<BpelDAOConnectionImpl> _connections = new ThreadLocal<BpelDAOConnectionImpl>();
+
+ public BpelDAOConnectionImpl(EntityManager mgr, TransactionManager txMgr, JpaOperator operator) {
+ super(mgr, txMgr, operator);
+ }
+
+ public static ThreadLocal<BpelDAOConnectionImpl> getThreadLocal() {
+ return _connections;
+ }
+
+ public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
+ BpelEventFilter efilter) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter,
+ BpelEventFilter efilter) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public ProcessInstanceDAO getInstance(Long iid) {
+ _txCtx.begin();
+ ProcessInstanceDAOImpl instance = _em.find(ProcessInstanceDAOImpl.class, iid);
+ _txCtx.commit();
+ return instance;
+ }
+
+ public MessageExchangeDAO createMessageExchange(char dir) {
+ _txCtx.begin();
+ MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir);
+ _em.persist(ret);
+ _txCtx.commit();
+ return ret;
+ }
+
+ public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
+ _txCtx.begin();
+ ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,version);
+ _em.persist(ret);
+ _txCtx.commit();
+ return ret;
+ }
+
+ public ProcessDAO createTransientProcess(Long id) {
+ ProcessDAOImpl ret = new ProcessDAOImpl(null, null, null, 0);
+ ret.setId(id);
+
+ return ret;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ProcessDAO getProcess(QName processId) {
+ _txCtx.begin();
+ List l = _em.createQuery("select x from ProcessDAOImpl x where x._processId = ?1")
+ .setParameter(1, processId.toString()).getResultList();
+ _txCtx.commit();
+ if (l.size() == 0) return null;
+ ProcessDAOImpl p = (ProcessDAOImpl) l.get(0);
+ return p;
+ }
+
+ public int getNumInstances(QName processId) {
+ ProcessDAO process = getProcess(processId);
+ if (process != null)
+ return process.getNumInstances();
+ else return -1;
+ }
+
+ public ScopeDAO getScope(Long siidl) {
+ _txCtx.begin();
+ ScopeDAO scopeDAO = _em.find(ScopeDAOImpl.class, siidl);
+ _txCtx.commit();
+ return scopeDAO;
+ }
+
+ public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
+ _txCtx.begin();
+ EventDAOImpl eventDao = new EventDAOImpl();
+ eventDao.setTstamp(new Timestamp(System.currentTimeMillis()));
+ eventDao.setType(BpelEvent.eventName(event));
+ String evtStr = event.toString();
+ eventDao.setDetail(evtStr.substring(0, Math.min(254, evtStr.length())));
+ 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);
+ _txCtx.commit();
+ }
+
+ private static String dateFilter(String filter) {
+ String date = Filter.getDateWithoutOp(filter);
+ String op = filter.substring(0,filter.indexOf(date));
+ Date dt = null;
+ try {
+ dt = ISO8601DateParser.parse(date);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ Timestamp ts = new Timestamp(dt.getTime());
+ return op + " '" + ts.toString() + "'";
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria) {
+ _txCtx.begin();
+ StringBuffer query = new StringBuffer();
+ query.append("select pi from ProcessInstanceDAOImpl as pi left join fetch pi._fault ");
+
+ if (criteria != null) {
+ // Building each clause
+ ArrayList<String> clauses = new ArrayList<String>();
+
+ // iid filter
+ if ( criteria.getIidFilter() != null ) {
+ StringBuffer filters = new StringBuffer();
+ List<String> iids = criteria.getIidFilter();
+ for (int m = 0; m < iids.size(); m++) {
+ filters.append(" pi._instanceId = ").append(iids.get(m));
+ if (m < iids.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters + ")");
+ }
+
+ // pid filter
+ if (criteria.getPidFilter() != null) {
+ StringBuffer filters = new StringBuffer();
+ List<String> pids = criteria.getPidFilter();
+ for (int m = 0; m < pids.size(); m++) {
+ filters.append(" pi._process._processId = '").append(pids.get(m)).append("'");
+ if (m < pids.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters + ")");
+ }
+
+ // name filter
+ if (criteria.getNameFilter() != null) {
+ String val = criteria.getNameFilter();
+ if (val.endsWith("*")) {
+ val = val.substring(0, val.length()-1) + "%";
+ }
+ //process type string begins with name space
+ //this could possibly match more than you want
+ //because the name space and name are stored together
+ clauses.add(" pi._process._processType like '%" + val + "'");
+ }
+
+ // name space filter
+ if (criteria.getNamespaceFilter() != null) {
+ //process type string begins with name space
+ //this could possibly match more than you want
+ //because the name space and name are stored together
+ clauses.add(" pi._process._processType like '{" +
+ criteria.getNamespaceFilter() + "%'");
+ }
+
+ // started filter
+ if (criteria.getStartedDateFilter() != null) {
+ for ( String ds : criteria.getStartedDateFilter() ) {
+ clauses.add(" pi._dateCreated " + dateFilter(ds));
+ }
+ }
+
+ // last-active filter
+ if (criteria.getLastActiveDateFilter() != null) {
+ for ( String ds : criteria.getLastActiveDateFilter() ) {
+ clauses.add(" pi._lastActive " + dateFilter(ds));
+ }
+ }
+
+ // status filter
+ if (criteria.getStatusFilter() != null) {
+ StringBuffer filters = new StringBuffer();
+ List<Short> states = criteria.convertFilterState();
+ for (int m = 0; m < states.size(); m++) {
+ filters.append(" pi._state = ").append(states.get(m));
+ if (m < states.size() - 1) filters.append(" or");
+ }
+ clauses.add(" (" + filters.toString() + ")");
+ }
+
+ // $property filter
+ if (criteria.getPropertyValuesFilter() != null) {
+ Map<String,String> props = criteria.getPropertyValuesFilter();
+ // join to correlation sets
+ query.append(" inner join pi._rootScope._correlationSets as cs");
+ int i = 0;
+ for (String propKey : props.keySet()) {
+ i++;
+ // join to props for each prop
+ query.append(" inner join cs._props as csp"+i);
+ // add clause for prop key and value
+ clauses.add(" csp"+i+".propertyKey = '"+propKey+
+ "' and csp"+i+".propertyValue = '"+
+ // spaces have to be escaped, might be better handled in InstanceFilter
+ props.get(propKey).replaceAll(" ", " ")+"'");
+ }
+ }
+
+ // order by
+ StringBuffer orderby = new StringBuffer("");
+ if (criteria.getOrders() != null) {
+ orderby.append(" order by");
+ List<String> orders = criteria.getOrders();
+ for (int m = 0; m < orders.size(); m++) {
+ String field = orders.get(m);
+ String ord = " asc";
+ if (field.startsWith("-")) {
+ ord = " desc";
+ }
+ String fieldName = " pi._instanceId";
+ if ( field.endsWith("name") || field.endsWith("namespace")) {
+ fieldName = " pi._process._processType";
+ }
+ if ( field.endsWith("version")) {
+ fieldName = " pi._process._version";
+ }
+ if ( field.endsWith("status")) {
+ fieldName = " pi._state";
+ }
+ if ( field.endsWith("started")) {
+ fieldName = " pi._dateCreated";
+ }
+ if ( field.endsWith("last-active")) {
+ fieldName = " pi._lastActive";
+ }
+ orderby.append(fieldName + ord);
+ if (m < orders.size() - 1) orderby.append(", ");
+ }
+
+ }
+
+ // Preparing the statement
+ if (clauses.size() > 0) {
+ query.append(" where");
+ for (int m = 0; m < clauses.size(); m++) {
+ query.append(clauses.get(m));
+ if (m < clauses.size() - 1) query.append(" and");
+ }
+ }
+
+ query.append(orderby);
+ }
+
+ if (__log.isDebugEnabled()) {
+ __log.debug(query.toString());
+ }
+
+ // criteria limit
+ Query pq = _em.createQuery(query.toString());
+ getJPADaoOperator().setBatchSize(pq, criteria.getLimit());
+ List<ProcessInstanceDAO> ql = pq.getResultList();
+
+ Collection<ProcessInstanceDAO> list = new ArrayList<ProcessInstanceDAO>();
+ int num = 0;
+ for (Iterator iterator = ql.iterator(); iterator.hasNext();) {
+ if(num++ > criteria.getLimit()) break;
+ ProcessInstanceDAO processInstanceDAO = (ProcessInstanceDAO) iterator.next();
+ list.add(processInstanceDAO);
+ }
+ _txCtx.commit();
+ return list;
+ }
+
+
+ public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
+ return instanceQuery(new InstanceFilter(expression));
+ }
+
+ public MessageExchangeDAO getMessageExchange(String mexid) {
+ return _em.find(MessageExchangeDAOImpl.class, mexid);
+ }
+
+ public void deleteMessageExchange(MessageExchangeDAO mexDao) {
+ _em.remove(mexDao);
+ }
+
+ public EntityManager getEntityManager() {
+ return _em;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<Long, Collection<CorrelationSetDAO>> getCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ if (instances.size() == 0) {
+ return new HashMap<Long, Collection<CorrelationSetDAO>>();
+ }
+ ArrayList<Long> iids = new ArrayList<Long>(instances.size());
+ for (ProcessInstanceDAO dao: instances) {
+ iids.add(dao.getInstanceId());
+ }
+ _txCtx.begin();
+ Collection<CorrelationSetDAOImpl> csets = _em.createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES).setParameter("instances", iids).getResultList();
+ _txCtx.commit();
+ Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long, Collection<CorrelationSetDAO>>();
+ for (CorrelationSetDAOImpl cset: csets) {
+ Long id = cset.getScope().getProcessInstance().getInstanceId();
+ Collection<CorrelationSetDAO> existing = map.get(id);
+ if (existing == null) {
+ existing = new ArrayList<CorrelationSetDAO>();
+ map.put(id, existing);
+ }
+ existing.add(cset);
+ }
+ return map;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<CorrelationSetDAO> getActiveCorrelationSets() {
+ _txCtx.begin();
+ Collection<CorrelationSetDAO> daos = _em.createNamedQuery(CorrelationSetDAOImpl.SELECT_ACTIVE_SETS).setParameter("state", ProcessState.STATE_ACTIVE).getResultList();
+ _txCtx.commit();
+ return daos;
+ }
+
+ public ProcessManagementDAO getProcessManagement() {
+ return new ProcessManagementDAOImpl(_em);
+ }
+
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrSetProperty.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,92 @@
+/*
+ * 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.bpel;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_CORSET_PROP")
+@NamedQueries({
+ @NamedQuery(name=CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS, query="delete from CorrSetProperty as p where p.corrSetId in(:corrSetIds)")
+})
+public class CorrSetProperty {
+ public final static String DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS = "DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Basic @Column(name="PROP_KEY")
+ private String propertyKey;
+ @Basic @Column(name="PROP_VALUE")
+ private String propertyValue;
+
+ @SuppressWarnings("unused")
+ @Basic @Column(name="CORRSET_ID", insertable=false, updatable=false, nullable=true)
+ private Long corrSetId;
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="CORRSET_ID")
+ private CorrelationSetDAOImpl _corrSet;
+
+ public CorrSetProperty() {
+ }
+ public CorrSetProperty(String propertyKey, String propertyValue) {
+ this.propertyKey = propertyKey;
+ this.propertyValue = propertyValue;
+ }
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+ public CorrelationSetDAOImpl getCorrSet() {
+ return _corrSet;
+ }
+
+ public void setCorrSet(CorrelationSetDAOImpl corrSet) {
+ _corrSet = corrSet;
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java?rev=986561&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/CorrelationSetDAOImpl.java Wed Aug 18 04:12:49 2010
@@ -0,0 +1,124 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+@Entity
+@Table(name="ODE_CORRELATION_SET")
+@NamedQueries({
+ @NamedQuery(name=CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS, query="delete from CorrelationSetDAOImpl as c where c._correlationSetId in (:ids)"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES, query="select c from CorrelationSetDAOImpl as c left join fetch c._scope left join fetch c._props where c._scope._processInstance._instanceId in (:instances)"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_PROCESS, query="select c._correlationSetId from CorrelationSetDAOImpl as c where c._scope._processInstance._process = :process"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_INSTANCE, query="select c._correlationSetId from CorrelationSetDAOImpl as c where c._scope._processInstance = :instance"),
+ @NamedQuery(name=CorrelationSetDAOImpl.SELECT_ACTIVE_SETS, query="select c from CorrelationSetDAOImpl as c left join fetch c._scope where c._scope._processInstance._state = (:state)")
+})
+public class CorrelationSetDAOImpl implements CorrelationSetDAO {
+ public final static String DELETE_CORRELATION_SETS_BY_IDS = "DELETE_CORRELATION_SETS_BY_IDS";
+ public final static String SELECT_CORRELATION_SETS_BY_INSTANCES = "SELECT_CORRELATION_SETS_BY_INSTANCES";
+ public final static String SELECT_CORRELATION_SET_IDS_BY_PROCESS = "SELECT_CORRELATION_SET_IDS_BY_PROCESS";
+ public final static String SELECT_CORRELATION_SET_IDS_BY_INSTANCE = "SELECT_CORRELATION_SET_IDS_BY_INSTANCE";
+ public final static String SELECT_ACTIVE_SETS = "SELECT_ACTIVE_SETS";
+
+ @Id @Column(name="CORRELATION_SET_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _correlationSetId;
+ @Basic @Column(name="NAME")
+ private String _name;
+ @Basic @Column(name="CORRELATION_KEY")
+ private String _correlationKey;
+
+ @OneToMany(targetEntity=CorrSetProperty.class,mappedBy="_corrSet",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
+ private Collection<CorrSetProperty> _props = new ArrayList<CorrSetProperty>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="SCOPE_ID")
+ private ScopeDAOImpl _scope;
+
+ public CorrelationSetDAOImpl() {}
+ public CorrelationSetDAOImpl(ScopeDAOImpl scope, String name) {
+ _name = name;
+ _scope = scope;
+ }
+
+ public Long getCorrelationSetId() {
+ return _correlationSetId;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public Map<QName, String> getProperties() {
+ HashMap<QName, String> map = new HashMap<QName, String>();
+ for (CorrSetProperty prop : _props) {
+ map.put(QName.valueOf(prop.getPropertyKey()), prop.getPropertyValue());
+ }
+ return map;
+ }
+
+ public ScopeDAO getScope() {
+ return _scope;
+ }
+
+ public CorrelationKey getValue() {
+ if (_correlationKey == null) return null;
+ return new CorrelationKey(_correlationKey);
+ }
+
+ public void setValue(QName[] names, CorrelationKey values) {
+ _correlationKey = values.toCanonicalString();
+ if (names != null)
+ for (int m = 0; m < names.length; m++) {
+ CorrSetProperty prop = new CorrSetProperty(names[m].toString(), values.getValues()[m]);
+ _props.add(prop);
+ prop.setCorrSet(this);
+ }
+ }
+
+ public ProcessDAO getProcess() {
+ return _scope.getProcessInstance().getProcess();
+ }
+ public ProcessInstanceDAO getInstance() {
+ return _scope.getProcessInstance();
+ }
+}