Author: jeff.yuchang
Date: 2011-03-21 01:29:45 -0400 (Mon, 21 Mar 2011)
New Revision: 1322
Modified:
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ModelAdaptor.java
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ProcessHistoryPluginImpl.java
Log:
*RIFTSAW-259, update the restful web service.
Modified:
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ModelAdaptor.java
===================================================================
---
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ModelAdaptor.java 2011-03-17
08:23:42 UTC (rev 1321)
+++
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ModelAdaptor.java 2011-03-21
05:29:45 UTC (rev 1322)
@@ -21,16 +21,21 @@
*/
package org.jboss.soa.bpel.console;
-import org.apache.ode.bpel.pmapi.*;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.pmapi.InstanceInfoListDocument;
+import org.apache.ode.bpel.pmapi.ProcessInfoListDocument;
+import org.apache.ode.bpel.pmapi.TInstanceInfo;
+import org.apache.ode.bpel.pmapi.TProcessInfo;
+import org.apache.ode.bpel.pmapi.TProcessStatus;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
import org.jboss.soa.bpel.console.util.Base64;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.List;
-import java.io.IOException;
-
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@@ -97,8 +102,9 @@
}
catch (IOException e)
{
- throw new RuntimeException("Failed to encode id", e);
+ throw new RuntimeException("Failed to decode id", e);
}
}
+
}
Modified:
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ProcessHistoryPluginImpl.java
===================================================================
---
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ProcessHistoryPluginImpl.java 2011-03-17
08:23:42 UTC (rev 1321)
+++
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/ProcessHistoryPluginImpl.java 2011-03-21
05:29:45 UTC (rev 1322)
@@ -3,11 +3,13 @@
*/
package org.jboss.soa.bpel.console;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
-import java.util.Map;
+import java.util.Set;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -53,30 +55,64 @@
String definitionkey, String status, long starttime, long endtime,
String correlationkey) {
- List<Event> events = ds.getInstanceEvents(definitionkey, new Timespan(starttime,
endtime, "Custom"), getStatus(status));
+ String dkey = null;
+ try {
+ dkey = URLDecoder.decode(definitionkey, "UTF-8");
+ } catch (UnsupportedEncodingException e1) {
+ throw new IllegalStateException("Decode definition key of " + definitionkey
+ " failed.");
+ }
+ List<Event> events = ds.getInstanceEvents(dkey, new Timespan(starttime, endtime,
"Custom"), getStatus(status));
List<String> instanceIds = null;
- if (correlationkey != null ) {
- instanceIds = ds.getProcessInstances(definitionkey, "correlation-key",
correlationkey);
+ if (correlationkey != null && !("".equals(correlationkey.trim()))) {
+ String ckey = null;
+ try {
+ ckey = URLDecoder.decode(correlationkey.replace("~", "="),
"UTF-8");
+ } catch (UnsupportedEncodingException e1) {
+ throw new IllegalStateException("Decode correlation key of " +
correlationkey + " failed.");
+ }
+ instanceIds = ds.getProcessInstances(dkey, "correlation-key", ckey);
}
- Map<String, HistoryProcessInstanceRef> hisInstances = new HashMap<String,
HistoryProcessInstanceRef>();
+ Set<String> historyInstanceIds = new HashSet<String>();
for(Event e : events)
{
if(instanceIds == null || instanceIds.contains(e.getProcessInstanceID())) {
if (e.getEventDetails().getCurrentState().equals(getStatus(status))) {
- HistoryProcessInstanceRef hi = createHistoryInstance(status, hisInstances, e);
- hisInstances.put(e.getProcessInstanceID(), hi);
+ historyInstanceIds.add(e.getProcessInstanceID());
}
}
}
- List<HistoryProcessInstanceRef> ref = new
ArrayList<HistoryProcessInstanceRef>();
- for (HistoryProcessInstanceRef hp : hisInstances.values()) {
- ref.add(hp);
+ List<HistoryProcessInstanceRef> refs = new
ArrayList<HistoryProcessInstanceRef>();
+ int i = 0;
+ for (String theInstanceID : historyInstanceIds) {
+ if (i > 10) {
+ //due to performance concern, we've just listed 10 history instances at most.
+ break;
+ }
+ List<Event> theEvents = ds.getPastActivities(theInstanceID);
+ HistoryProcessInstanceRef ref = new HistoryProcessInstanceRef();
+ for (Event e : theEvents) {
+ ref.setProcessInstanceId(e.getProcessInstanceID());
+ ref.setState(status);
+ for (Tuple tuple : e.getDataElement()) {
+ if ("correlation-key".equals(tuple.getName())) {
+ ref.setKey(tuple.getValue());
+ }
+ if ("process-start-time".equals(tuple.getName())) {
+ ref.setStartTime(new Date(new Long(tuple.getValue())));
+ }
+ if ("process-end-time".equals(tuple.getName())) {
+ ref.setEndTime(new Date(new Long(tuple.getValue())));
+ }
+ }
+ }
+ refs.add(ref);
+ i++;
}
- return ref;
+ return refs;
}
private State getStatus(String status) {
@@ -91,30 +127,5 @@
}
return null;
}
-
-
-
- private HistoryProcessInstanceRef createHistoryInstance(String status, Map<String,
HistoryProcessInstanceRef> hisInstances, Event e) {
- HistoryProcessInstanceRef hi = null;
- if (!hisInstances.containsKey(e.getProcessInstanceID())) {
- hi = new HistoryProcessInstanceRef();
- } else {
- hi = hisInstances.get(e.getProcessInstanceID());
- }
- hi.setProcessDefinitionId(e.getProcessInstanceID());
- hi.setState(status);
- for (Tuple tuple : e.getDataElement()) {
- if ("correlation-key".equals(tuple.getName())) {
- hi.setKey(tuple.getValue());
- }
- if ("process-start-time".equals(tuple.getName())) {
- hi.setStartTime(new Date(new Long(tuple.getValue())));
- }
- if ("process-end-time".equals(tuple.getName())) {
- hi.setEndTime(new Date(new Long(tuple.getValue())));
- }
- }
- return hi;
- }
}
Show replies by date