You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2008/05/23 01:26:18 UTC

svn commit: r659307 [21/24] - in /ode/trunk: axis2-war/src/main/webapp/WEB-INF/ axis2-war/src/main/webapp/WEB-INF/classes/ axis2-war/src/test/resources/XSDReferences/ axis2-war/src/test/resources/XSDReferences/BPMN/ axis2-war/src/test/resources/XSDRefe...

Modified: ode/trunk/dao-jpa-db/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-db/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa-db/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java (original)
+++ ode/trunk/dao-jpa-db/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java Thu May 22 16:25:57 2008
@@ -1,296 +1,296 @@
-/*
- * 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.test;
-
-import junit.framework.TestCase;
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.FaultDAO;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern;
-import org.apache.ode.bpel.iapi.MessageExchange.Status;
-import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl;
-import org.apache.ode.il.EmbeddedGeronimoFactory;
-import org.apache.ode.utils.GUID;
-import org.hsqldb.jdbc.jdbcDataSource;
-
-import javax.persistence.EntityManager;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.xml.namespace.QName;
-import java.util.Collection;
-import java.util.Properties;
-
-public class SelectObjectTest extends TestCase {
-	
-	private EntityManager em;
-	private static final String TEST_NS = "http://org.apache.ode.jpa.test";
-	private String[] correlationKeys = { "key1", "key2" };
-	private String[] actions = { "action1","action2" };
-	private CorrelationKey key1 = new CorrelationKey(1,correlationKeys);
-	private static final String CORRELATOR_ID1 = "testCorrelator1";
-	private static final String CORRELATOR_ID2 = "testCorrelator2";
-
-    TransactionManager _txm;
-    DataSource _ds;
-    BPELDAOConnectionFactoryImpl factory;
-
-    @Override
-	protected void setUp() throws Exception {
-        jdbcDataSource hsqlds = new jdbcDataSource();
-        hsqlds.setDatabase("jdbc:hsqldb:mem:" + new GUID().toString());
-        hsqlds.setUser("sa");
-        hsqlds.setPassword("");
-        _ds = hsqlds;
-
-        _txm = new EmbeddedGeronimoFactory().getTransactionManager();
-
-        factory = new BPELDAOConnectionFactoryImpl();
-        factory.setDataSource(_ds);
-        factory.setTransactionManager(_txm);
-        Properties props = new Properties();
-        props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
-        factory.init(props);
-
-        _txm.begin();
-	}
-
-	public void testGetObject() throws Exception {
-        new InsertObjectTest().createStuff(factory);
-
-        _txm.commit();
-        _txm.begin();        
-
-        BpelDAOConnection conn = factory.getConnection();
-		
-		// Assert the ProcessDAO
-		ProcessDAO p = conn.getProcess(new QName(TEST_NS,"testPID1"));
-		assertNotNull( p );
-		Collection<ProcessInstanceDAO> insts = p.findInstance(key1);
-		assertNotNull( insts );
-		assertTrue( insts.size() > 0 );
-		assertNotNull(p.getType());
-		assertNotNull(p.getProcessId());
-		assertEquals( p.getVersion() , 1 );
-		
-		// Assert the CorrelatorDAO
-		CorrelatorDAO corr = p.getCorrelator(CORRELATOR_ID1);
-		assertNotNull( corr );
-		assertEquals(corr.getCorrelatorId(),CORRELATOR_ID1);
-		
-		// Assert the MessageRouteDAO
-		MessageRouteDAO route = corr.findRoute(key1);
-		assertNotNull( route );
-		assertEquals(route.getGroupId(),"testRoute" );
-		assertEquals(route.getIndex() , 1 );
-		assertNotNull(route.getTargetInstance() );
-
-		// Assert the ProcessInstanceDAO
-		for ( ProcessInstanceDAO inst : insts ) {
-			Long id = inst.getInstanceId();
-			assertNotNull( id );
-			
-			ProcessInstanceDAO inst2 = conn.getInstance(id);
-			assertSame(inst2,inst);
-			
-			ProcessInstanceDAO inst3 = p.getInstance(id);
-			assertSame( inst3 , inst );
-			
-			Long mon = inst.genMonotonic();
-			assertEquals(inst.getActivityFailureCount() , 2);
-			assertNotNull(inst.getActivityFailureDateTime() );
-			assertNotNull(inst.getCreateTime() );
-			assertTrue(inst.getExecutionState().length > 0 );
-			assertNotNull(inst.getLastActiveTime() );
-			assertSame(inst.getProcess() , p );
-			assertEquals(inst.getPreviousState() , 0);
-			assertEquals(inst.getState() , 1);
-			
-			// Assert the Root ScopeDAO
-			ScopeDAO rs = inst.getRootScope();
-			assertNotNull( rs );
-			assertNotNull(rs.getChildScopes());
-			ScopeDAO child1 = null;
-			for ( ScopeDAO childItr : rs.getChildScopes()){
-				child1 = childItr;
-				break;
-			}
-			assertNotNull(child1);
-			assertNotNull(rs.getCorrelationSets());
-			assertEquals(rs.getCorrelationSets().size() , 0 );
-			assertEquals(rs.getModelId(),1);
-			assertEquals(rs.getName(),"Root");
-			assertTrue(rs.getParentScope() == null);
-			assertNotNull(rs.getPartnerLinks());
-			assertEquals(rs.getPartnerLinks().size() ,0);
-			assertSame(rs.getProcessInstance(),inst);
-			assertNotNull(rs.getScopeInstanceId());
-			assertEquals(rs.getState(),ScopeStateEnum.ACTIVE);
-			assertNotNull(rs.getVariables());
-			assertEquals(rs.getVariables().size(),0);
-			
-		
-			// Assert the ActivityRecoveryDAO
-			assertNotNull(inst.getActivityRecoveries());
-			ActivityRecoveryDAO rec1 = null;
-			for (ActivityRecoveryDAO recItr : inst.getActivityRecoveries()) {
-				rec1 = recItr;
-				break;
-			}
-			assertNotNull(rec1);
-			String tmpAct = rec1.getActions();
-//			assertEquals(rec1.getActionsList(),actions);
-//			assertEquals(rec1.getActivityId(),4);
-//			assertEquals(rec1.getChannel(),"testChannel1");
-//			assertNotNull(rec1.getDateTime());
-//			assertNotNull(rec1.getDetails());
-//			assertEquals(rec1.getReason(),"testReason1");
-//			assertEquals(rec1.getRetries(),2);
-			
-			// Assert the CorrelationSetDAO
-			//assertNotNull(inst.getCorrelationSets());
-			//CorrelationSetDAO cs1 = null;
-			//for ( CorrelationSetDAO csItr : inst.getCorrelationSets() ) {
-			//	cs1 = csItr;
-			//	break;
-			//}
-			//assertNotNull(cs1);
-			
-			// Assert the FaultDAO
-			FaultDAO fault = inst.getFault();
-			assertNotNull(fault);
-			assertEquals(fault.getActivityId(),1);
-			assertNotNull(fault.getData());
-			assertEquals(fault.getExplanation(),"testExplanation");
-			assertEquals(fault.getLineNo(),1);
-			assertEquals(fault.getName(),new QName(TEST_NS,"testFault"));
-			
-			// Assert MessageExchangeDAO
-			CorrelatorDAO ic = inst.getInstantiatingCorrelator();
-			assertNotNull(ic);
-			assertEquals(ic.getCorrelatorId(),CORRELATOR_ID1);
-			// The message is dequeued but not persisted
-			MessageExchangeDAO me = ic.dequeueMessage(key1);
-			assertNotNull(me);
-			assertEquals(me.getCallee(),new QName(TEST_NS,"testCallee"));
-			//XXX assertEquals(me.getPropagateTransactionFlag(),false);
-			assertEquals(me.getChannel(),"testChannel");
-			//XXX assertEquals(me.getCorrelationId(),"testCorrelationId");
-			//assertNotNull(me.getCreateTime());
-			assertEquals(me.getDirection(), MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE);
-			assertEquals(me.getMessageExchangeId(), "testId");
-			assertNotNull(me.getEPR());
-			assertEquals(me.getFault().toString(),"testFault");
-			assertEquals(me.getFaultExplanation(),"testFaultExplanation");
-			assertSame(me.getInstance(),inst);
-			assertEquals(me.getOperation(),"testOperation");
-			assertNotNull(me.getPartnerLink());
-			assertEquals(me.getPartnerLinkModelId(),1);
-			assertEquals(me.getPattern(), MessageExchangePattern.UNKNOWN);
-			assertEquals(me.getPortType(),new QName(TEST_NS,"testPortType"));
-			assertSame(me.getProcess(),p);
-			assertEquals(me.getProperty("testProp1Key"),"testProp1");
-			assertNotNull(me.getRequest());
-			assertNotNull(me.getResponse());
-			assertEquals(me.getStatus(), Status.NEW);
-			
-			// Assert MessageDAO
-			MessageDAO m = me.getRequest();
-			assertNotNull(m.getData());
-			//XXX assertSame(m.getMessageExchange(),me);
-			assertEquals(m.getType(),new QName(TEST_NS,"testRequest"));
-			
-			
-			//Assert Child ScopeDAO
-			assertNotNull(inst.getScopes());
-			assertTrue(inst.getScopes().size() > 0);
-			assertNotNull(inst.getScopes("Child1"));
-			assertTrue(inst.getScopes("Child1").size() == 1);
-			ScopeDAO childS = inst.getScopes("Child1").iterator().next();
-			assertSame(childS,child1);
-			assertSame(childS.getParentScope(),rs);
-			assertNotNull(childS.getChildScopes());
-			assertEquals(childS.getChildScopes().size(), 0);
-			assertNotNull(childS.getVariables());
-			assertTrue(childS.getVariables().size() > 0);
-			assertNotNull(childS.getVariable("var1"));
-			XmlDataDAO chsVar = childS.getVariable("var1");
-			assertNotNull(childS.getPartnerLinks());
-			assertTrue(childS.getPartnerLinks().size() > 0);
-			PartnerLinkDAO spl = childS.getPartnerLinks().iterator().next();
-			assertSame(spl,me.getPartnerLink());
-			assertSame(spl,childS.getPartnerLink(spl.getPartnerLinkModelId()));
-			assertNotNull(childS.getCorrelationSets());
-			assertTrue(childS.getCorrelationSets().size() > 0);
-			assertNotNull(childS.getCorrelationSet("TestCorrelationSet1"));
-			
-			// Assert CorrelationSetDAO
-			CorrelationSetDAO cs = childS.getCorrelationSet("TestCorrelationSet1");
-			assertEquals(cs.getName(),"TestCorrelationSet1");
-			assertNotNull(cs.getProperties());
-			assertTrue(cs.getProperties().size() > 0);
-			assertSame(cs.getScope(),childS);
-			assertNotNull(cs.getValue());
-			assertEquals(cs.getProperties().get(new QName(TEST_NS,"name1")),"key1");
-			
-			
-			// Assert PartnerLinkDAO
-			assertNotNull(spl.getMyEPR());
-			assertEquals(spl.getMyRoleName(),"MyRole1");
-			assertEquals(spl.getMyRoleServiceName(),new QName(TEST_NS,"testRoleService"));
-			assertEquals(spl.getMySessionId(),"TestMySessionID");
-			assertNotNull(spl.getPartnerEPR());
-			assertEquals(spl.getPartnerLinkModelId(),1);
-			assertEquals(spl.getPartnerLinkName(),"Test PartnerLink1");
-			assertEquals(spl.getPartnerRoleName(),"PartnerRole1");
-			assertEquals(spl.getPartnerSessionId(),"TestPartnerSessionID");
-			
-			// Assert Variables
-			assertNotNull(inst.getVariables("var1", 2));
-			assertEquals(inst.getVariables("var1", 2).length,1);
-			XmlDataDAO[] vars = inst.getVariables("var1", 2);
-			assertSame(chsVar,vars[0]);
-			assertNotNull(vars[0].get());
-			assertEquals(vars[0].getName(),"var1");
-			assertEquals(vars[0].getProperty("key1"),"prop1");
-			assertSame(vars[0].getScopeDAO(),childS);
-			
-		}
-	}
-
-	@Override
-	protected void tearDown() throws Exception {
-        _txm.commit();
-		_txm = null;
-        _ds = null;
-    }
-	
-}
+/*
+ * 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.test;
+
+import junit.framework.TestCase;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.FaultDAO;
+import org.apache.ode.bpel.dao.MessageDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.MessageRouteDAO;
+import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.ScopeStateEnum;
+import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern;
+import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl;
+import org.apache.ode.il.EmbeddedGeronimoFactory;
+import org.apache.ode.utils.GUID;
+import org.hsqldb.jdbc.jdbcDataSource;
+
+import javax.persistence.EntityManager;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import javax.xml.namespace.QName;
+import java.util.Collection;
+import java.util.Properties;
+
+public class SelectObjectTest extends TestCase {
+	
+	private EntityManager em;
+	private static final String TEST_NS = "http://org.apache.ode.jpa.test";
+	private String[] correlationKeys = { "key1", "key2" };
+	private String[] actions = { "action1","action2" };
+	private CorrelationKey key1 = new CorrelationKey(1,correlationKeys);
+	private static final String CORRELATOR_ID1 = "testCorrelator1";
+	private static final String CORRELATOR_ID2 = "testCorrelator2";
+
+    TransactionManager _txm;
+    DataSource _ds;
+    BPELDAOConnectionFactoryImpl factory;
+
+    @Override
+	protected void setUp() throws Exception {
+        jdbcDataSource hsqlds = new jdbcDataSource();
+        hsqlds.setDatabase("jdbc:hsqldb:mem:" + new GUID().toString());
+        hsqlds.setUser("sa");
+        hsqlds.setPassword("");
+        _ds = hsqlds;
+
+        _txm = new EmbeddedGeronimoFactory().getTransactionManager();
+
+        factory = new BPELDAOConnectionFactoryImpl();
+        factory.setDataSource(_ds);
+        factory.setTransactionManager(_txm);
+        Properties props = new Properties();
+        props.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
+        factory.init(props);
+
+        _txm.begin();
+	}
+
+	public void testGetObject() throws Exception {
+        new InsertObjectTest().createStuff(factory);
+
+        _txm.commit();
+        _txm.begin();        
+
+        BpelDAOConnection conn = factory.getConnection();
+		
+		// Assert the ProcessDAO
+		ProcessDAO p = conn.getProcess(new QName(TEST_NS,"testPID1"));
+		assertNotNull( p );
+		Collection<ProcessInstanceDAO> insts = p.findInstance(key1);
+		assertNotNull( insts );
+		assertTrue( insts.size() > 0 );
+		assertNotNull(p.getType());
+		assertNotNull(p.getProcessId());
+		assertEquals( p.getVersion() , 1 );
+		
+		// Assert the CorrelatorDAO
+		CorrelatorDAO corr = p.getCorrelator(CORRELATOR_ID1);
+		assertNotNull( corr );
+		assertEquals(corr.getCorrelatorId(),CORRELATOR_ID1);
+		
+		// Assert the MessageRouteDAO
+		MessageRouteDAO route = corr.findRoute(key1);
+		assertNotNull( route );
+		assertEquals(route.getGroupId(),"testRoute" );
+		assertEquals(route.getIndex() , 1 );
+		assertNotNull(route.getTargetInstance() );
+
+		// Assert the ProcessInstanceDAO
+		for ( ProcessInstanceDAO inst : insts ) {
+			Long id = inst.getInstanceId();
+			assertNotNull( id );
+			
+			ProcessInstanceDAO inst2 = conn.getInstance(id);
+			assertSame(inst2,inst);
+			
+			ProcessInstanceDAO inst3 = p.getInstance(id);
+			assertSame( inst3 , inst );
+			
+			Long mon = inst.genMonotonic();
+			assertEquals(inst.getActivityFailureCount() , 2);
+			assertNotNull(inst.getActivityFailureDateTime() );
+			assertNotNull(inst.getCreateTime() );
+			assertTrue(inst.getExecutionState().length > 0 );
+			assertNotNull(inst.getLastActiveTime() );
+			assertSame(inst.getProcess() , p );
+			assertEquals(inst.getPreviousState() , 0);
+			assertEquals(inst.getState() , 1);
+			
+			// Assert the Root ScopeDAO
+			ScopeDAO rs = inst.getRootScope();
+			assertNotNull( rs );
+			assertNotNull(rs.getChildScopes());
+			ScopeDAO child1 = null;
+			for ( ScopeDAO childItr : rs.getChildScopes()){
+				child1 = childItr;
+				break;
+			}
+			assertNotNull(child1);
+			assertNotNull(rs.getCorrelationSets());
+			assertEquals(rs.getCorrelationSets().size() , 0 );
+			assertEquals(rs.getModelId(),1);
+			assertEquals(rs.getName(),"Root");
+			assertTrue(rs.getParentScope() == null);
+			assertNotNull(rs.getPartnerLinks());
+			assertEquals(rs.getPartnerLinks().size() ,0);
+			assertSame(rs.getProcessInstance(),inst);
+			assertNotNull(rs.getScopeInstanceId());
+			assertEquals(rs.getState(),ScopeStateEnum.ACTIVE);
+			assertNotNull(rs.getVariables());
+			assertEquals(rs.getVariables().size(),0);
+			
+		
+			// Assert the ActivityRecoveryDAO
+			assertNotNull(inst.getActivityRecoveries());
+			ActivityRecoveryDAO rec1 = null;
+			for (ActivityRecoveryDAO recItr : inst.getActivityRecoveries()) {
+				rec1 = recItr;
+				break;
+			}
+			assertNotNull(rec1);
+			String tmpAct = rec1.getActions();
+//			assertEquals(rec1.getActionsList(),actions);
+//			assertEquals(rec1.getActivityId(),4);
+//			assertEquals(rec1.getChannel(),"testChannel1");
+//			assertNotNull(rec1.getDateTime());
+//			assertNotNull(rec1.getDetails());
+//			assertEquals(rec1.getReason(),"testReason1");
+//			assertEquals(rec1.getRetries(),2);
+			
+			// Assert the CorrelationSetDAO
+			//assertNotNull(inst.getCorrelationSets());
+			//CorrelationSetDAO cs1 = null;
+			//for ( CorrelationSetDAO csItr : inst.getCorrelationSets() ) {
+			//	cs1 = csItr;
+			//	break;
+			//}
+			//assertNotNull(cs1);
+			
+			// Assert the FaultDAO
+			FaultDAO fault = inst.getFault();
+			assertNotNull(fault);
+			assertEquals(fault.getActivityId(),1);
+			assertNotNull(fault.getData());
+			assertEquals(fault.getExplanation(),"testExplanation");
+			assertEquals(fault.getLineNo(),1);
+			assertEquals(fault.getName(),new QName(TEST_NS,"testFault"));
+			
+			// Assert MessageExchangeDAO
+			CorrelatorDAO ic = inst.getInstantiatingCorrelator();
+			assertNotNull(ic);
+			assertEquals(ic.getCorrelatorId(),CORRELATOR_ID1);
+			// The message is dequeued but not persisted
+			MessageExchangeDAO me = ic.dequeueMessage(key1);
+			assertNotNull(me);
+			assertEquals(me.getCallee(),new QName(TEST_NS,"testCallee"));
+			//XXX assertEquals(me.getPropagateTransactionFlag(),false);
+			assertEquals(me.getChannel(),"testChannel");
+			//XXX assertEquals(me.getCorrelationId(),"testCorrelationId");
+			//assertNotNull(me.getCreateTime());
+			assertEquals(me.getDirection(), MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE);
+			assertEquals(me.getMessageExchangeId(), "testId");
+			assertNotNull(me.getEPR());
+			assertEquals(me.getFault().toString(),"testFault");
+			assertEquals(me.getFaultExplanation(),"testFaultExplanation");
+			assertSame(me.getInstance(),inst);
+			assertEquals(me.getOperation(),"testOperation");
+			assertNotNull(me.getPartnerLink());
+			assertEquals(me.getPartnerLinkModelId(),1);
+			assertEquals(me.getPattern(), MessageExchangePattern.UNKNOWN);
+			assertEquals(me.getPortType(),new QName(TEST_NS,"testPortType"));
+			assertSame(me.getProcess(),p);
+			assertEquals(me.getProperty("testProp1Key"),"testProp1");
+			assertNotNull(me.getRequest());
+			assertNotNull(me.getResponse());
+			assertEquals(me.getStatus(), Status.NEW);
+			
+			// Assert MessageDAO
+			MessageDAO m = me.getRequest();
+			assertNotNull(m.getData());
+			//XXX assertSame(m.getMessageExchange(),me);
+			assertEquals(m.getType(),new QName(TEST_NS,"testRequest"));
+			
+			
+			//Assert Child ScopeDAO
+			assertNotNull(inst.getScopes());
+			assertTrue(inst.getScopes().size() > 0);
+			assertNotNull(inst.getScopes("Child1"));
+			assertTrue(inst.getScopes("Child1").size() == 1);
+			ScopeDAO childS = inst.getScopes("Child1").iterator().next();
+			assertSame(childS,child1);
+			assertSame(childS.getParentScope(),rs);
+			assertNotNull(childS.getChildScopes());
+			assertEquals(childS.getChildScopes().size(), 0);
+			assertNotNull(childS.getVariables());
+			assertTrue(childS.getVariables().size() > 0);
+			assertNotNull(childS.getVariable("var1"));
+			XmlDataDAO chsVar = childS.getVariable("var1");
+			assertNotNull(childS.getPartnerLinks());
+			assertTrue(childS.getPartnerLinks().size() > 0);
+			PartnerLinkDAO spl = childS.getPartnerLinks().iterator().next();
+			assertSame(spl,me.getPartnerLink());
+			assertSame(spl,childS.getPartnerLink(spl.getPartnerLinkModelId()));
+			assertNotNull(childS.getCorrelationSets());
+			assertTrue(childS.getCorrelationSets().size() > 0);
+			assertNotNull(childS.getCorrelationSet("TestCorrelationSet1"));
+			
+			// Assert CorrelationSetDAO
+			CorrelationSetDAO cs = childS.getCorrelationSet("TestCorrelationSet1");
+			assertEquals(cs.getName(),"TestCorrelationSet1");
+			assertNotNull(cs.getProperties());
+			assertTrue(cs.getProperties().size() > 0);
+			assertSame(cs.getScope(),childS);
+			assertNotNull(cs.getValue());
+			assertEquals(cs.getProperties().get(new QName(TEST_NS,"name1")),"key1");
+			
+			
+			// Assert PartnerLinkDAO
+			assertNotNull(spl.getMyEPR());
+			assertEquals(spl.getMyRoleName(),"MyRole1");
+			assertEquals(spl.getMyRoleServiceName(),new QName(TEST_NS,"testRoleService"));
+			assertEquals(spl.getMySessionId(),"TestMySessionID");
+			assertNotNull(spl.getPartnerEPR());
+			assertEquals(spl.getPartnerLinkModelId(),1);
+			assertEquals(spl.getPartnerLinkName(),"Test PartnerLink1");
+			assertEquals(spl.getPartnerRoleName(),"PartnerRole1");
+			assertEquals(spl.getPartnerSessionId(),"TestPartnerSessionID");
+			
+			// Assert Variables
+			assertNotNull(inst.getVariables("var1", 2));
+			assertEquals(inst.getVariables("var1", 2).length,1);
+			XmlDataDAO[] vars = inst.getVariables("var1", 2);
+			assertSame(chsVar,vars[0]);
+			assertNotNull(vars[0].get());
+			assertEquals(vars[0].getName(),"var1");
+			assertEquals(vars[0].getProperty("key1"),"prop1");
+			assertSame(vars[0].getScopeDAO(),childS);
+			
+		}
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+        _txm.commit();
+		_txm = null;
+        _ds = null;
+    }
+	
+}

Modified: ode/trunk/dao-jpa-db/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa-db/src/test/resources/META-INF/persistence.xml?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa-db/src/test/resources/META-INF/persistence.xml (original)
+++ ode/trunk/dao-jpa-db/src/test/resources/META-INF/persistence.xml Thu May 22 16:25:57 2008
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?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
@@ -17,44 +17,44 @@
   ~ 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.ScopeDAOImpl</class>
-        <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</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"/>
-             
-            <property name="openjpa.ConnectionProperties"
-                value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/derby/ode-test-db;userid=sa;create=false,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
-            -->
-
-            <!-- Properties for an embedded Derby connection -->
-            <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
-            <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)"/>
-            -->
-
-
-        </properties>
-    </persistence-unit>
-</persistence>
-
+<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.ScopeDAOImpl</class>
+        <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</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"/>
+             
+            <property name="openjpa.ConnectionProperties"
+                value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/derby/ode-test-db;userid=sa;create=false,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
+            -->
+
+            <!-- Properties for an embedded Derby connection -->
+            <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+            <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)"/>
+            -->
+
+
+        </properties>
+    </persistence-unit>
+</persistence>
+

Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,136 +1,136 @@
-/*
- * 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.dao.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.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import java.util.Date;
-
-
-@Entity
-@Table(name="ODE_ACTIVITY_RECOVERY")
-public class ActivityRecoveryDAOImpl implements ActivityRecoveryDAO {
-
-    @Id @Column(name="ID")
-    @GeneratedValue(strategy= GenerationType.AUTO)
-    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;
-
-    // _instances is unused because this is a one-way relationship at the database level
-    @SuppressWarnings("unused")
-    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(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;
-    }
-}
+/*
+ * 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.dao.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.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import java.util.Date;
+
+
+@Entity
+@Table(name="ODE_ACTIVITY_RECOVERY")
+public class ActivityRecoveryDAOImpl implements ActivityRecoveryDAO {
+
+    @Id @Column(name="ID")
+    @GeneratedValue(strategy= GenerationType.AUTO)
+    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;
+
+    // _instances is unused because this is a one-way relationship at the database level
+    @SuppressWarnings("unused")
+    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(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;
+    }
+}

Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java Thu May 22 16:25:57 2008
@@ -1,303 +1,303 @@
-/*
- * 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 java.sql.Timestamp;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-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.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.evt.BpelEvent;
-import org.apache.ode.bpel.evt.ScopeEvent;
-import org.apache.ode.utils.ISO8601DateParser;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.apache.openjpa.persistence.OpenJPAQuery;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-public class BPELDAOConnectionImpl implements BpelDAOConnection {
-	
-	static final Log __log = LogFactory.getLog(BPELDAOConnectionImpl.class);
-	
-	EntityManager _em;
-
-    public BPELDAOConnectionImpl(EntityManager em) {
-        _em = em;
-    }
-
-    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) {
-        ProcessInstanceDAOImpl instance = _em.find(ProcessInstanceDAOImpl.class, iid);
-        return instance;
-    }
-
-    public void close() {
-        _em = null;
-    }
-
-    public MessageExchangeDAO createMessageExchange(String mexId, char dir) {
-        MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(mexId, dir);
-        
-        _em.persist(ret);
-        return ret;
-    }
-
-    public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
-        ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,version);
-        _em.persist(ret);
-        return ret;
-    }
-
-    public ProcessDAO getProcess(QName processId) {
-        List l = _em.createQuery("select x from ProcessDAOImpl x where x._processId = ?1")
-                .setParameter(1, processId.toString()).getResultList();
-        if (l.size() == 0) return null;
-        ProcessDAOImpl p = (ProcessDAOImpl) l.get(0);
-        return p;
-    }
-
-    public ScopeDAO getScope(Long siidl) {
-        return _em.find(ScopeDAOImpl.class, siidl);
-    }
-
-    public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
-        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);
-	}
-    
-    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) {
-        StringBuffer query = new StringBuffer();
-        query.append("select pi from ProcessInstanceDAOImpl as pi");
-
-        if (criteria != null) {
-            // Building each clause
-            ArrayList<String> clauses = new ArrayList<String>();
-            
-            // pid filter
-            if (criteria.getPidFilter() != null)
-                clauses.add(" pi._process._processId = '" + criteria.getPidFilter() + "'");
-            
-            // 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("&#32;", " ")+"'");
-                }
-            }
-            
-            // 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());
-        OpenJPAQuery kq = OpenJPAPersistence.cast(pq);
-        kq.getFetchPlan().setFetchBatchSize(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);            
-        }     
-        
-        return list;
-	}
-
-   
-	public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
-	    return instanceQuery(new InstanceFilter(expression));
-	}
-
-	public void setEntityManger(EntityManager em) {
-		_em = em;
-	}
-	
-    public MessageExchangeDAO getMessageExchange(String mexid) {
-        List l = _em.createQuery("select x from MessageExchangeDAOImpl x where x._id = ?1")
-        .setParameter(1, mexid).getResultList();
-        if (l.size() == 0) return null;
-        MessageExchangeDAOImpl m = (MessageExchangeDAOImpl) l.get(0);
-        return m;
-    }
-
-    public EntityManager getEntityManager() {
-        return _em;
-    }
-}
+/*
+ * 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 java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+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.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
+import org.apache.ode.utils.ISO8601DateParser;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class BPELDAOConnectionImpl implements BpelDAOConnection {
+	
+	static final Log __log = LogFactory.getLog(BPELDAOConnectionImpl.class);
+	
+	EntityManager _em;
+
+    public BPELDAOConnectionImpl(EntityManager em) {
+        _em = em;
+    }
+
+    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) {
+        ProcessInstanceDAOImpl instance = _em.find(ProcessInstanceDAOImpl.class, iid);
+        return instance;
+    }
+
+    public void close() {
+        _em = null;
+    }
+
+    public MessageExchangeDAO createMessageExchange(String mexId, char dir) {
+        MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(mexId, dir);
+        
+        _em.persist(ret);
+        return ret;
+    }
+
+    public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
+        ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,version);
+        _em.persist(ret);
+        return ret;
+    }
+
+    public ProcessDAO getProcess(QName processId) {
+        List l = _em.createQuery("select x from ProcessDAOImpl x where x._processId = ?1")
+                .setParameter(1, processId.toString()).getResultList();
+        if (l.size() == 0) return null;
+        ProcessDAOImpl p = (ProcessDAOImpl) l.get(0);
+        return p;
+    }
+
+    public ScopeDAO getScope(Long siidl) {
+        return _em.find(ScopeDAOImpl.class, siidl);
+    }
+
+    public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO instance) {
+        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);
+	}
+    
+    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) {
+        StringBuffer query = new StringBuffer();
+        query.append("select pi from ProcessInstanceDAOImpl as pi");
+
+        if (criteria != null) {
+            // Building each clause
+            ArrayList<String> clauses = new ArrayList<String>();
+            
+            // pid filter
+            if (criteria.getPidFilter() != null)
+                clauses.add(" pi._process._processId = '" + criteria.getPidFilter() + "'");
+            
+            // 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("&#32;", " ")+"'");
+                }
+            }
+            
+            // 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());
+        OpenJPAQuery kq = OpenJPAPersistence.cast(pq);
+        kq.getFetchPlan().setFetchBatchSize(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);            
+        }     
+        
+        return list;
+	}
+
+   
+	public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
+	    return instanceQuery(new InstanceFilter(expression));
+	}
+
+	public void setEntityManger(EntityManager em) {
+		_em = em;
+	}
+	
+    public MessageExchangeDAO getMessageExchange(String mexid) {
+        List l = _em.createQuery("select x from MessageExchangeDAOImpl x where x._id = ?1")
+        .setParameter(1, mexid).getResultList();
+        if (l.size() == 0) return null;
+        MessageExchangeDAOImpl m = (MessageExchangeDAOImpl) l.get(0);
+        return m;
+    }
+
+    public EntityManager getEntityManager() {
+        return _em;
+    }
+}

Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,99 +1,99 @@
-/*
- * 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.common.CorrelationKey;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.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.ManyToOne;
-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")
-public class CorrelationSetDAOImpl implements CorrelationSetDAO {
-
-	@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.ALL})
-    private Collection<CorrSetProperty> _props = new ArrayList<CorrSetProperty>();
-    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(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();
-	    for (int m = 0; m < names.length; m++) {
-            CorrSetProperty prop = new CorrSetProperty(names[m].toString(), values.getValues()[m]);
-            _props.add(prop);
-            prop.setCorrSet(this);
-        }
-	}
-}
+/*
+ * 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.common.CorrelationKey;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.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.ManyToOne;
+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")
+public class CorrelationSetDAOImpl implements CorrelationSetDAO {
+
+	@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.ALL})
+    private Collection<CorrSetProperty> _props = new ArrayList<CorrSetProperty>();
+    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(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();
+	    for (int m = 0; m < names.length; m++) {
+            CorrSetProperty prop = new CorrSetProperty(names[m].toString(), values.getValues()[m]);
+            _props.add(prop);
+            prop.setCorrSet(this);
+        }
+	}
+}

Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,117 +1,117 @@
-/*
- * 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.common.CorrelationKey;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-
-import javax.persistence.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-@Entity
-@Table(name="ODE_CORRELATOR")
-@NamedQueries({
-    @NamedQuery(name="RouteByCKey", query="SELECT route " +
-            "FROM MessageRouteDAOImpl as route " +
-            "WHERE route._correlationKey = :ckey and route._correlator._process._processType = :ptype")
-        })
-public class CorrelatorDAOImpl extends OpenJPADAO implements CorrelatorDAO {
-
-    @Id @Column(name="CORRELATOR_ID")
-    @GeneratedValue(strategy=GenerationType.AUTO)
-    private Long _correlatorId;
-    @Basic @Column(name="CORRELATOR_KEY")
-    private String _correlatorKey;
-    @OneToMany(targetEntity=MessageRouteDAOImpl.class,mappedBy="_correlator",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
-    private Collection<MessageRouteDAOImpl> _routes = new ArrayList<MessageRouteDAOImpl>();
-    @OneToMany(targetEntity=MessageExchangeDAOImpl.class,mappedBy="_correlator",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
-    private Collection<MessageExchangeDAOImpl> _exchanges = new ArrayList<MessageExchangeDAOImpl>();
-    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROC_ID")
-    private ProcessDAOImpl _process;
-
-    public CorrelatorDAOImpl(){}
-    public CorrelatorDAOImpl(String correlatorKey, ProcessDAOImpl process) {
-        _correlatorKey = correlatorKey;
-        _process = process;
-    }
-
-    public void addRoute(String routeGroupId, ProcessInstanceDAO target, int index, CorrelationKey correlationKey) {
-        MessageRouteDAOImpl mr = new MessageRouteDAOImpl(correlationKey,
-                routeGroupId, index, (ProcessInstanceDAOImpl) target, this);
-        _routes.add(mr);
-    }
-
-    public MessageExchangeDAO dequeueMessage(CorrelationKey correlationKey) {
-        MessageExchangeDAOImpl toRemove = null;
-        for (Iterator<MessageExchangeDAOImpl> itr=_exchanges.iterator(); itr.hasNext();){
-            MessageExchangeDAOImpl mex = itr.next();
-            if (mex.getCorrelationKeys().contains(correlationKey)) {
-                toRemove = mex;
-            }
-        }
-        _exchanges.remove(toRemove);
-        return toRemove;
-    }
-
-    public void enqueueMessage(MessageExchangeDAO mex,
-                               CorrelationKey[] correlationKeys) {
-        MessageExchangeDAOImpl mexImpl = (MessageExchangeDAOImpl) mex;
-        for (CorrelationKey key : correlationKeys ) {
-            mexImpl.addCorrelationKey(key);
-        }
-        _exchanges.add(mexImpl);
-        mexImpl.setCorrelator(this);
-
-    }
-
-    public MessageRouteDAO findRoute(CorrelationKey correlationKey) {
-        Query qry = getEM().createNamedQuery("RouteByCKey");
-        qry.setParameter("ckey", correlationKey.toCanonicalString());
-        qry.setParameter("ptype", _process.getType().toString());
-        List<MessageRouteDAO> routes = (List<MessageRouteDAO>) qry.getResultList();
-        if (routes.size() > 0) return routes.get(0);
-        else return null;
-    }
-
-    public String getCorrelatorId() {
-        return _correlatorKey;
-    }
-
-    public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
-        // remove route across all correlators of the process
-        ((ProcessInstanceDAOImpl)target).removeRoutes(routeGroupId);
-    }
-
-    void removeLocalRoutes(String routeGroupId, ProcessInstanceDAO target) {
-        for (Iterator<MessageRouteDAOImpl> itr=_routes.iterator(); itr.hasNext(); ) {
-            MessageRouteDAOImpl mr = itr.next();
-            if ( mr.getGroupId().equals(routeGroupId) && mr.getTargetInstance().equals(target)) {
-                itr.remove();
-                getEM().remove(mr);
-            }
-        }
-    }
-}
+/*
+ * 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.common.CorrelationKey;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.MessageRouteDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+@Entity
+@Table(name="ODE_CORRELATOR")
+@NamedQueries({
+    @NamedQuery(name="RouteByCKey", query="SELECT route " +
+            "FROM MessageRouteDAOImpl as route " +
+            "WHERE route._correlationKey = :ckey and route._correlator._process._processType = :ptype")
+        })
+public class CorrelatorDAOImpl extends OpenJPADAO implements CorrelatorDAO {
+
+    @Id @Column(name="CORRELATOR_ID")
+    @GeneratedValue(strategy=GenerationType.AUTO)
+    private Long _correlatorId;
+    @Basic @Column(name="CORRELATOR_KEY")
+    private String _correlatorKey;
+    @OneToMany(targetEntity=MessageRouteDAOImpl.class,mappedBy="_correlator",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+    private Collection<MessageRouteDAOImpl> _routes = new ArrayList<MessageRouteDAOImpl>();
+    @OneToMany(targetEntity=MessageExchangeDAOImpl.class,mappedBy="_correlator",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+    private Collection<MessageExchangeDAOImpl> _exchanges = new ArrayList<MessageExchangeDAOImpl>();
+    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROC_ID")
+    private ProcessDAOImpl _process;
+
+    public CorrelatorDAOImpl(){}
+    public CorrelatorDAOImpl(String correlatorKey, ProcessDAOImpl process) {
+        _correlatorKey = correlatorKey;
+        _process = process;
+    }
+
+    public void addRoute(String routeGroupId, ProcessInstanceDAO target, int index, CorrelationKey correlationKey) {
+        MessageRouteDAOImpl mr = new MessageRouteDAOImpl(correlationKey,
+                routeGroupId, index, (ProcessInstanceDAOImpl) target, this);
+        _routes.add(mr);
+    }
+
+    public MessageExchangeDAO dequeueMessage(CorrelationKey correlationKey) {
+        MessageExchangeDAOImpl toRemove = null;
+        for (Iterator<MessageExchangeDAOImpl> itr=_exchanges.iterator(); itr.hasNext();){
+            MessageExchangeDAOImpl mex = itr.next();
+            if (mex.getCorrelationKeys().contains(correlationKey)) {
+                toRemove = mex;
+            }
+        }
+        _exchanges.remove(toRemove);
+        return toRemove;
+    }
+
+    public void enqueueMessage(MessageExchangeDAO mex,
+                               CorrelationKey[] correlationKeys) {
+        MessageExchangeDAOImpl mexImpl = (MessageExchangeDAOImpl) mex;
+        for (CorrelationKey key : correlationKeys ) {
+            mexImpl.addCorrelationKey(key);
+        }
+        _exchanges.add(mexImpl);
+        mexImpl.setCorrelator(this);
+
+    }
+
+    public MessageRouteDAO findRoute(CorrelationKey correlationKey) {
+        Query qry = getEM().createNamedQuery("RouteByCKey");
+        qry.setParameter("ckey", correlationKey.toCanonicalString());
+        qry.setParameter("ptype", _process.getType().toString());
+        List<MessageRouteDAO> routes = (List<MessageRouteDAO>) qry.getResultList();
+        if (routes.size() > 0) return routes.get(0);
+        else return null;
+    }
+
+    public String getCorrelatorId() {
+        return _correlatorKey;
+    }
+
+    public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
+        // remove route across all correlators of the process
+        ((ProcessInstanceDAOImpl)target).removeRoutes(routeGroupId);
+    }
+
+    void removeLocalRoutes(String routeGroupId, ProcessInstanceDAO target) {
+        for (Iterator<MessageRouteDAOImpl> itr=_routes.iterator(); itr.hasNext(); ) {
+            MessageRouteDAOImpl mr = itr.next();
+            if ( mr.getGroupId().equals(routeGroupId) && mr.getTargetInstance().equals(target)) {
+                itr.remove();
+                getEM().remove(mr);
+            }
+        }
+    }
+}

Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,93 +1,93 @@
-/*
- * 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.dao.FaultDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.Table;
-import javax.xml.namespace.QName;
-
-
-@Entity
-@Table(name="ODE_FAULT")
-public class FaultDAOImpl implements FaultDAO {
-
-	@Id @Column(name="FAULT_ID") 
-	@GeneratedValue(strategy=GenerationType.AUTO)
-	private Long _id;
-	@Basic @Column(name="NAME")
-    private String _name;
-	@Basic @Column(name="MESSAGE", length=4000)
-    private String _explanation;
-	@Lob @Column(name="DATA")
-    private String _data;
-	@Basic @Column(name="LINE_NUMBER")
-    private int _lineNo;
-	@Basic @Column(name="ACTIVITY_ID")
-    private int _activityId;
-
-	public FaultDAOImpl() {}
-	public FaultDAOImpl(QName faultName, String explanation, int faultLineNo,
-			int activityId, Element faultMessage) {
-		_name = faultName.toString();
-		_explanation = explanation;
-		_lineNo = faultLineNo;
-		_activityId = activityId;
-		_data = (faultMessage == null)?null:DOMUtils.domToString(faultMessage);
-	}
-	
-	public int getActivityId() {
-		return _activityId;
-	}
-
-	public Element getData() {
-		Element ret = null;
-		
-		try {
-			ret = (_data == null)?null:DOMUtils.stringToDOM(_data);
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-		
-		return ret;
-	}
-
-	public String getExplanation() {
-		return _explanation;
-	}
-
-	public int getLineNo() {
-		return _lineNo;
-	}
-
-	public QName getName() {
-		return _name == null ? null : QName.valueOf(_name);
-	}
-
-}
+/*
+ * 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.dao.FaultDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+import javax.xml.namespace.QName;
+
+
+@Entity
+@Table(name="ODE_FAULT")
+public class FaultDAOImpl implements FaultDAO {
+
+	@Id @Column(name="FAULT_ID") 
+	@GeneratedValue(strategy=GenerationType.AUTO)
+	private Long _id;
+	@Basic @Column(name="NAME")
+    private String _name;
+	@Basic @Column(name="MESSAGE", length=4000)
+    private String _explanation;
+	@Lob @Column(name="DATA")
+    private String _data;
+	@Basic @Column(name="LINE_NUMBER")
+    private int _lineNo;
+	@Basic @Column(name="ACTIVITY_ID")
+    private int _activityId;
+
+	public FaultDAOImpl() {}
+	public FaultDAOImpl(QName faultName, String explanation, int faultLineNo,
+			int activityId, Element faultMessage) {
+		_name = faultName.toString();
+		_explanation = explanation;
+		_lineNo = faultLineNo;
+		_activityId = activityId;
+		_data = (faultMessage == null)?null:DOMUtils.domToString(faultMessage);
+	}
+	
+	public int getActivityId() {
+		return _activityId;
+	}
+
+	public Element getData() {
+		Element ret = null;
+		
+		try {
+			ret = (_data == null)?null:DOMUtils.stringToDOM(_data);
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+		
+		return ret;
+	}
+
+	public String getExplanation() {
+		return _explanation;
+	}
+
+	public int getLineNo() {
+		return _lineNo;
+	}
+
+	public QName getName() {
+		return _name == null ? null : QName.valueOf(_name);
+	}
+
+}