Author: jeff.yuchang
Date: 2011-04-03 22:45:16 -0400 (Sun, 03 Apr 2011)
New Revision: 1348
Modified:
trunk/distribution/src/main/assembly/bin.xml
trunk/samples/quickstart/management/readme.txt
trunk/samples/quickstart/management/src/org/jboss/riftsaw/management/ManagementClient.java
Log:
*RIFTSAW-365, added a method for retriving the historic process instances.
Modified: trunk/distribution/src/main/assembly/bin.xml
===================================================================
--- trunk/distribution/src/main/assembly/bin.xml 2011-04-03 12:49:32 UTC (rev 1347)
+++ trunk/distribution/src/main/assembly/bin.xml 2011-04-04 02:45:16 UTC (rev 1348)
@@ -113,6 +113,7 @@
<include>quickstart/simple_invoke/**</include>
<include>quickstart/simple_pick/**</include>
<include>quickstart/while_wait/**</include>
+ <include>quickstart/management/**</include>
<include>tutorial/BPEL-BluePrint1/**</include>
<include>tutorial/BPEL-BluePrint2/**</include>
<include>tutorial/BPEL-BluePrint3/**</include>
Modified: trunk/samples/quickstart/management/readme.txt
===================================================================
--- trunk/samples/quickstart/management/readme.txt 2011-04-03 12:49:32 UTC (rev 1347)
+++ trunk/samples/quickstart/management/readme.txt 2011-04-04 02:45:16 UTC (rev 1348)
@@ -3,22 +3,35 @@
This is a simple example to demonstrate our management APIs that are exposed as Restful
services.
-This example shows three restful services:
+To run this example with best output is to do as following:
+Go to $sample/quickstart/simple_correlation, run following commands:
+
+1. ant deploy
+2. ant sendhello
+3. ant sendgoodbye
+4. ant sendhello2
+
+With above commands, you've got one active process instance, one completed process
instance.
+
+
+This example shows four restful services:
+
1). all deployments: This service returns all of deployed artifacts on the server.
2). all process definitions: This services returns all of process definitions that are
deployed on server.
3). active process instances for simple_correlation example process definition.
+4). historic process instances for simple_correlation example process definition.
By default, all of restful services are secured by form authentication, except the status
service and the deployments
service.
In the example, firstly, we've invoked the restful service, and then with the JSON
result, we've used the
-third party library (Gson) to marshall the JSON data into Java Object, where you can find
it on the gwt-console-rpc.jar.
+third party library (Gson) to marshall the JSON data into Java Objects, where you can
find it on the gwt-console-rpc.jar.
-These all restful services are built from the bpm console project, not on the riftsaw
core components.
+These all restful services are built from the bpm console project, not on the riftsaw
core itself.
for details on bpm console, please refer to
https://github.com/bpmc/bpm-console/
some handy URLs:
-http://localhost:8080/gwt-console-server/rs/server/resources/riftsaw RiftSaw Restful
Services document
\ No newline at end of file
+http://localhost:8080/gwt-console-server/rs/server/resources/riftsaw RiftSaw Restful
Services document in html format.
\ No newline at end of file
Modified:
trunk/samples/quickstart/management/src/org/jboss/riftsaw/management/ManagementClient.java
===================================================================
---
trunk/samples/quickstart/management/src/org/jboss/riftsaw/management/ManagementClient.java 2011-04-03
12:49:32 UTC (rev 1347)
+++
trunk/samples/quickstart/management/src/org/jboss/riftsaw/management/ManagementClient.java 2011-04-04
02:45:16 UTC (rev 1348)
@@ -6,6 +6,9 @@
import org.jboss.bpm.console.client.model.*;
import java.io.IOException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
import org.jboss.soa.bpel.console.ModelAdaptor;
import com.google.gson.*;
@@ -23,6 +26,8 @@
private static final String authentication_url =
"http://localhost:8080/gwt-console-server/rs/identity/secure/j_security_check";
+ private static final String history_search_url =
"http://localhost:8080/gwt-console-server/rs/history/search";
+
public void showAllDeployments() throws Exception {
System.out.println("-----------------------------");
System.out.println("Get all of deployments: ");
@@ -76,6 +81,35 @@
}
}
+
+ public void getHistoricProcessInstance() throws Exception {
+ String processId =
"{http://www.jboss.org/bpel/examples}HelloGoodbye-1";
+ String encodedId = URLEncoder.encode(processId, "UTF-8");
+ String status = "COMPLETED";
+
+ Long starttime = new java.util.Date(103, 1, 1).getTime();
+ Long endtime = new java.util.Date().getTime();
+
+ String search_url = history_search_url + "?definitionkey=" + encodedId
+ "&status=" + status
+ + "&starttime="+starttime +
"&endtime=" + endtime;
+
+ System.out.println("-----------------------------");
+ System.out.println("Get historic process instances from process definition
of : " + processId );
+
+ String result = getDataFromService(search_url, "GET",
"admin", "password");
+ System.out.println("-----------------------------");
+ System.out.println("Marshall the Json data into java class.");
+
+ Gson gson = GsonFactory.createInstance();
+ HistoryProcessInstanceRefWrapper wrapper = gson.fromJson(result,
HistoryProcessInstanceRefWrapper.class);
+
+ for (HistoryProcessInstanceRef ref: wrapper.getDefinitions()) {
+ System.out.println("historic instance id is: " +
ref.getProcessInstanceId() + " definition key is: "
+ +
URLDecoder.decode(ref.getProcessDefinitionId(), "UTF-8"));
+ }
+
+ }
+
private String getDataFromService(String urlpath, String method, String username,
String password ) throws Exception{
HttpClient httpclient = new HttpClient();
@@ -128,6 +162,7 @@
client.showAllDeployments();
client.showAllDefinitions();
client.getActiveProcessInstance();
+ client.getHistoricProcessInstance();
}