Author: boisvert
Date: Tue Dec 2 15:53:10 2008
New Revision: 722680
URL: http://svn.apache.org/viewvc?rev=722680&view=rev
Log:
ODE-444 Improve performance of InstanceManagement service
Modified:
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java
ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/InstanceManagement.java
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ActivityRecoveryTest.java
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
Modified:
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java
Tue Dec 2 15:53:10 2008
@@ -125,7 +125,8 @@
// ODE-385 please fix me
@Test
public void testGetScopeInfo() throws Exception {
- OMElement root = _client.buildMessage("listAllInstances", new String[]
{}, new String[] {});
+ OMElement root = _client.buildMessage("listInstances", new String[]
{"filter", "order", "limit"},
+ new String[] {"name=DynPartnerMain", "", "10"});
OMElement result = sendToIM(root);
String siid = result.getFirstElement().getFirstChildWithName(new
QName(Namespaces.ODE_PMAPI, "instance-info"))
.getFirstChildWithName(new QName(Namespaces.ODE_PMAPI,
"root-scope"))
Modified:
ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/InstanceManagement.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/InstanceManagement.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/InstanceManagement.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/InstanceManagement.java
Tue Dec 2 15:53:10 2008
@@ -124,12 +124,29 @@
*/
InstanceInfoListDocument listInstances(String filter, String order, int
limit);
+ /**
+ * List instances and only return summary information about the instance,
+ * combined with all correlation properties.
+ *
+ * @param filter See listInstances' filter argument
+ * @param order See listInstances' order argument
+ * @param limit maximum number of instances to return
+ * @return list of matching instances
+ */
+ InstanceInfoListDocument listInstancesSummary(String filter, String order,
int limit);
+
+ /**
+ * @deprecated As of Ode 1.3, this method is deprecated in favor of
+ * listInstances(filter, order, limit)
+ */
InstanceInfoListDocument queryInstances(String query);
/**
* List all instances in the default (database) order.
* @see #listInstances(String, String, int)
* @return list of matching instances
+ * @deprecated As of Ode 1.3, this method is deprecated in favor of
+ * listInstancesSummary(filter, order, limit)
*/
InstanceInfoListDocument listAllInstances();
@@ -138,6 +155,8 @@
* @see #listInstances(String, String, int)
* @param limit maximum number of instances to return
* @return list of matching instances
+ * @deprecated As of Ode 1.3, this method is deprecated in favor of
+ * listInstancesSummary(filter, order, limit)
*/
InstanceInfoListDocument listAllInstancesWithLimit(int limit);
Modified:
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
Tue Dec 2 15:53:10 2008
@@ -18,14 +18,16 @@
*/
package org.apache.ode.bpel.dao;
-import org.apache.ode.bpel.common.BpelEventFilter;
-import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.evt.BpelEvent;
-
-import javax.xml.namespace.QName;
import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.evt.BpelEvent;
/**
@@ -64,6 +66,8 @@
*/
Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria);
+ Collection<ProcessInstanceDAO> instanceQuery(String expression);
+
/**
* Insert a BPEL event into the database.
* @param event a BPEL event
@@ -91,11 +95,11 @@
void close();
- Collection<ProcessInstanceDAO> instanceQuery(String expression);
+
+ Map<Long, Collection<CorrelationSetDAO>>
getCorrelationSets(Collection<ProcessInstanceDAO> instances);
ProcessDAO createProcess(QName pid, QName type, String guid, long version);
-
/**
* Create a message exchange.
* @param dir type of message exchange
@@ -104,4 +108,5 @@
MessageExchangeDAO createMessageExchange(char dir);
MessageExchangeDAO getMessageExchange(String mexid);
+
}
Modified:
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java
Tue Dec 2 15:53:10 2008
@@ -67,4 +67,5 @@
* @return Map with the property qualified name as key and value as Map
value.
*/
public Map<QName, String> getProperties();
+
}
Modified:
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
Tue Dec 2 15:53:10 2008
@@ -19,6 +19,22 @@
package org.apache.ode.bpel.engine;
+import java.io.File;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.QName;
+
import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -116,21 +132,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
/**
* Implentation of the Process and InstanceManagement APIs.
*
@@ -266,8 +267,7 @@
}
// We have to do this after we set the property, since the
- // ProcessConf object
- // is immutable.
+ // ProcessConf object is immutable.
ProcessConf proc = _store.getProcessConfiguration(pid);
if (proc == null)
throw new ProcessNotFoundException("ProcessNotFound:" + pid);
@@ -289,7 +289,6 @@
final TInstanceInfoList infolist = ret.addNewInstanceInfoList();
final InstanceFilter instanceFilter = new InstanceFilter(filter,
order, limit);
try {
-
_db.exec(new BpelDatabase.Callable<Object>() {
public Object run(BpelDAOConnection conn) {
Collection<ProcessInstanceDAO> instances =
conn.instanceQuery(instanceFilter);
@@ -306,12 +305,42 @@
return ret;
}
+ public InstanceInfoListDocument listInstancesSummary(String filter, String
order, int limit) {
+ InstanceInfoListDocument ret =
InstanceInfoListDocument.Factory.newInstance();
+ final TInstanceInfoList infolist = ret.addNewInstanceInfoList();
+ final InstanceFilter instanceFilter = new InstanceFilter(filter,
order, limit);
+ try {
+ _db.exec(new BpelDatabase.Callable<Object>() {
+ public Object run(BpelDAOConnection conn) {
+ Collection<ProcessInstanceDAO> instances =
conn.instanceQuery(instanceFilter);
+ Map<Long, Collection<CorrelationSetDAO>> icsets =
conn.getCorrelationSets(instances);
+ for (ProcessInstanceDAO instance : instances) {
+ TInstanceInfo info = infolist.addNewInstanceInfo();
+ fillInstanceSummary(info, instance);
+ Collection<CorrelationSetDAO> csets =
icsets.get(instance.getInstanceId());
+ if (csets != null) {
+ for (CorrelationSetDAO cset: csets) {
+ Map<QName, String> props =
cset.getProperties();
+ fillProperties(info, instance, props);
+ }
+ }
+ }
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ __log.error("Exception while listing instances", e);
+ throw new ProcessingException("Exception while listing instances:
" + e.toString());
+ }
+ return ret;
+ }
+
public InstanceInfoListDocument listAllInstances() {
- return listInstances(null, null, Integer.MAX_VALUE);
+ return listInstancesSummary(null, null, Integer.MAX_VALUE);
}
public InstanceInfoListDocument listAllInstancesWithLimit(int limit) {
- return listInstances(null, null, limit);
+ return listInstancesSummary(null, null, limit);
}
public InstanceInfoDocument getInstanceInfo(Long iid) throws
InstanceNotFoundException {
@@ -864,13 +893,22 @@
});
}
- private void fillInstanceInfo(TInstanceInfo info, ProcessInstanceDAO
instance) {
+ private void fillProperties(TInstanceInfo info, ProcessInstanceDAO
instance, Map<QName, String> props) {
+ TInstanceInfo.CorrelationProperties corrProperties =
info.addNewCorrelationProperties();
+ for (Map.Entry<QName, String> property : props.entrySet()) {
+ TCorrelationProperty tproperty =
corrProperties.addNewCorrelationProperty();
+ // not setting correlation-set id here -- too inconvenient for
performance
+ // tproperty.setCsetid("" + cset.getCorrelationSetId());
+ tproperty.setPropertyName(property.getKey());
+ tproperty.setStringValue(property.getValue());
+ }
+ }
+
+ private void fillInstanceSummary(TInstanceInfo info, ProcessInstanceDAO
instance) {
info.setIid("" + instance.getInstanceId());
ProcessDAO processDAO = instance.getProcess();
info.setPid(processDAO.getProcessId().toString());
info.setProcessName(processDAO.getType());
- if (instance.getRootScope() != null)
- info.setRootScope(genScopeRef(instance.getRootScope()));
info.setDtStarted(toCalendar(instance.getCreateTime()));
info.setDtLastActive(toCalendar(instance.getLastActiveTime()));
info.setStatus(__psc.cvtInstanceStatus(instance.getState()));
@@ -881,9 +919,21 @@
faultInfo.setAiid(instance.getFault().getActivityId());
faultInfo.setLineNumber(instance.getFault().getLineNo());
}
+ }
+
+ private void fillInstanceInfo(TInstanceInfo info, ProcessInstanceDAO
instance) {
+ fillInstanceSummary(info, instance);
+
+ if (instance.getRootScope() != null)
+ info.setRootScope(genScopeRef(instance.getRootScope()));
ProcessInstanceDAO.EventsFirstLastCountTuple flc =
instance.getEventsFirstLastCount();
TInstanceInfo.EventInfo eventInfo = info.addNewEventInfo();
+ if (flc != null) {
+ eventInfo.setFirstDtime(toCalendar(flc.first));
+ eventInfo.setLastDtime(toCalendar(flc.last));
+ eventInfo.setCount(flc.count);
+ }
// Setting valued correlation properties
if (!instance.getCorrelationSets().isEmpty()) {
@@ -898,12 +948,6 @@
}
}
- if (flc != null) {
- eventInfo.setFirstDtime(toCalendar(flc.first));
- eventInfo.setLastDtime(toCalendar(flc.last));
- eventInfo.setCount(flc.count);
- }
-
if (instance.getActivityFailureCount() > 0) {
TFailuresInfo failures = info.addNewFailures();
failures.setDtFailure(toCalendar(instance.getActivityFailureDateTime()));
Modified:
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
Tue Dec 2 15:53:10 2008
@@ -25,6 +25,7 @@
import org.apache.ode.bpel.common.InstanceFilter;
import org.apache.ode.bpel.common.ProcessFilter;
import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.dao.ProcessInstanceDAO;
@@ -350,4 +351,19 @@
}
});
}
+
+ public Map<Long, Collection<CorrelationSetDAO>>
getCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long,
Collection<CorrelationSetDAO>>();
+ for (ProcessInstanceDAO instance: instances) {
+ Long id = instance.getInstanceId();
+ Collection<CorrelationSetDAO> existing = map.get(id);
+ if (existing == null) {
+ existing = new ArrayList<CorrelationSetDAO>();
+ map.put(id, existing);
+ }
+ existing.addAll(instance.getCorrelationSets());
+ }
+ return map;
+ }
+
}
Modified:
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ActivityRecoveryTest.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ActivityRecoveryTest.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ActivityRecoveryTest.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ActivityRecoveryTest.java
Tue Dec 2 15:53:10 2008
@@ -305,7 +305,7 @@
}
protected TInstanceInfo lastInstance() {
- TInstanceInfoList instances =
_management.listAllInstances().getInstanceInfoList();
+ TInstanceInfoList instances = _management.listInstances("", "",
1000).getInstanceInfoList();
return
instances.getInstanceInfoArray(instances.sizeOfInstanceInfoArray() - 1);
}
Modified:
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
Tue Dec 2 15:53:10 2008
@@ -18,15 +18,40 @@
*/
package org.apache.ode.daohib.bpel;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+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.InstanceFilter;
-import org.apache.ode.bpel.dao.*;
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+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.daohib.SessionManager;
-import org.apache.ode.daohib.bpel.hobj.*;
+import org.apache.ode.daohib.bpel.hobj.HBpelEvent;
+import org.apache.ode.daohib.bpel.hobj.HCorrelationSet;
+import org.apache.ode.daohib.bpel.hobj.HLargeData;
+import org.apache.ode.daohib.bpel.hobj.HMessageExchange;
+import org.apache.ode.daohib.bpel.hobj.HProcess;
+import org.apache.ode.daohib.bpel.hobj.HProcessInstance;
+import org.apache.ode.daohib.bpel.hobj.HScope;
import org.apache.ode.daohib.bpel.ql.HibernateInstancesQueryCompiler;
import org.apache.ode.ql.eval.skel.CommandEvaluator;
import org.apache.ode.ql.tree.Builder;
@@ -42,12 +67,6 @@
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Projections;
-import javax.xml.namespace.QName;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.sql.Timestamp;
-import java.util.*;
-
/**
* Hibernate-based [EMAIL PROTECTED] BpelDAOConnection} implementation.
*/
@@ -245,4 +264,29 @@
return result;
}
+ @SuppressWarnings("unchecked")
+ public Map<Long, Collection<CorrelationSetDAO>>
getCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ if (instances.size() == 0) {
+ return new HashMap<Long, Collection<CorrelationSetDAO>>();
+ }
+ Long[] iids = new Long[instances.size()];
+ int i=0;
+ for (ProcessInstanceDAO dao: instances) {
+ iids[i] = dao.getInstanceId();
+ i++;
+ }
+ Collection<HCorrelationSet> csets =
_session.getNamedQuery(HCorrelationSet.SELECT_CORSETS_BY_INSTANCES).setParameterList("instances",
iids).list();
+ Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long,
Collection<CorrelationSetDAO>>();
+ for (HCorrelationSet cset: csets) {
+ Long id = cset.getInstance().getId();
+ Collection<CorrelationSetDAO> existing = map.get(id);
+ if (existing == null) {
+ existing = new ArrayList<CorrelationSetDAO>();
+ map.put(id, existing);
+ }
+ existing.add(new CorrelationSetDaoImpl(_sm, cset));
+ }
+ return map;
+ }
+
}
Modified:
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java
(original)
+++
ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java
Tue Dec 2 15:53:10 2008
@@ -27,10 +27,12 @@
* @hibernate.class table="BPEL_CORRELATION_SET"
* @hibernate.query name="DELETE_CORSETS_BY_INSTANCE" query="delete from
HCorrelationSet as c where c.instance = :instance"
* @hibernate.query name="DELETE_CORSETS_BY_PROCESS" query="delete from
HCorrelationSet as c where c.process = :process"
+ * @hibernate.query name="SELECT_CORSETS_BY_INSTANCES" query="from
HCorrelationSet as c left join fetch c.properties where c.instance.id in
(:instances)"
*/
public class HCorrelationSet extends HObject{
public static final String DELETE_CORSETS_BY_INSTANCE =
"DELETE_CORSETS_BY_INSTANCE";
public static final String DELETE_CORSETS_BY_PROCESS =
"DELETE_CORSETS_BY_PROCESS";
+ public static final String SELECT_CORSETS_BY_INSTANCES =
"SELECT_CORSETS_BY_INSTANCES";
private HProcess _process;
private HProcessInstance _instance;
Modified:
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
Tue Dec 2 15:53:10 2008
@@ -24,6 +24,7 @@
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;
@@ -38,6 +39,7 @@
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.CorrelationSetDAO;
import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.dao.ProcessInstanceDAO;
@@ -277,8 +279,7 @@
int num = 0;
for (Iterator iterator = ql.iterator(); iterator.hasNext();) {
if(num++ > criteria.getLimit()) break;
- ProcessInstanceDAO processInstanceDAO = (ProcessInstanceDAO)
iterator
- .next();
+ ProcessInstanceDAO processInstanceDAO = (ProcessInstanceDAO)
iterator.next();
list.add(processInstanceDAO);
}
@@ -305,4 +306,28 @@
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());
+ }
+ Collection<CorrelationSetDAOImpl> csets =
_em.createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES).setParameter("instances",
iids).getResultList();
+ 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;
+ }
+
}
Modified:
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
Tue Dec 2 15:53:10 2008
@@ -46,11 +46,13 @@
@Table(name="ODE_CORRELATION_SET")
@NamedQueries({
@NamedQuery(name=CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_PROCESS,
query="delete from CorrelationSetDAOImpl as c where c._scope in (select s from
ScopeDAOImpl s where s._processInstance._process = :process)"),
-
@NamedQuery(name=CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_INSTANCE,
query="delete from CorrelationSetDAOImpl as c where c._scope in (select s from
ScopeDAOImpl s where s._processInstance = :instance)")
+
@NamedQuery(name=CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_INSTANCE,
query="delete from CorrelationSetDAOImpl as c where c._scope in (select s from
ScopeDAOImpl s where s._processInstance = :instance)"),
+
@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)")
})
public class CorrelationSetDAOImpl implements CorrelationSetDAO {
public final static String DELETE_CORRELATION_SETS_BY_PROCESS =
"DELETE_CORRELATION_SETS_BY_PROCESS";
- public final static String DELETE_CORRELATION_SETS_BY_INSTANCE =
"DELETE_CORRELATION_SETS_BY_INSTANCE";
+ public final static String DELETE_CORRELATION_SETS_BY_INSTANCE =
"DELETE_CORRELATION_SETS_BY_INSTANCE";
+ public final static String SELECT_CORRELATION_SETS_BY_INSTANCES =
"SELECT_CORRELATION_SETS_BY_INSTANCES";
@Id @Column(name="CORRELATION_SET_ID")
@GeneratedValue(strategy=GenerationType.AUTO)
Modified:
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java?rev=722680&r1=722679&r2=722680&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
Tue Dec 2 15:53:10 2008
@@ -131,6 +131,11 @@
return ret;
}
+ @SuppressWarnings("unchecked")
+ public Collection<CorrelationSetDAO>
selectCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ return
getEM().createNamedQuery(CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_INSTANCE).setParameter("instances",
instances).getResultList();
+ }
+
public void delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
if(__log.isDebugEnabled()) __log.debug("Cleaning up instance
Data with " + cleanupCategories);