[jbpm-commits] JBoss JBPM SVN: r2515 - in jbpm3/trunk/modules/gwt-console: server/src/main/java/org/jboss/bpm/console/server/dao and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Oct 9 15:52:08 EDT 2008
Author: heiko.braun at jboss.com
Date: 2008-10-09 15:52:07 -0400 (Thu, 09 Oct 2008)
New Revision: 2515
Modified:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
Log:
Implement delete operation on RemoteListView's
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -26,10 +26,7 @@
import org.jboss.bpm.console.server.dao.DAOFactory;
import org.jboss.bpm.console.server.dao.ProcessDAO;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
+import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.servlet.http.HttpServletRequest;
@@ -41,9 +38,8 @@
@Path("process")
public class ProcessManagement
{
+ private ProcessDAO processDAO;
- private ProcessDAO processDAO;
-
public ProcessManagement()
{
this.processDAO = DAOFactory.createProcessDefinitionDAO();
@@ -51,16 +47,28 @@
@GET
@Path("definitions")
- @Produces("application/json")
+ @Produces("application/json")
public ProcessDefinitionWrapper getDefinitionsJSON(
@Context
HttpServletRequest request
- )
- {
- System.out.println("Remote user: " + request.getRemoteUser());
+ )
+ {
return new ProcessDefinitionWrapper( processDAO.getAllProcessDefinitions() );
}
+ @POST
+ @Path("definitions/{id}/remove")
+ @Produces("application/json")
+ public ProcessDefinitionWrapper removeDefinitionsJSON(
+ @PathParam("id")
+ long processId,
+ @Context
+ HttpServletRequest request
+ )
+ {
+ return new ProcessDefinitionWrapper( processDAO.removeProcessDefinition(processId) );
+ }
+
@GET
@Path("definitions/{id}/instances")
@Produces("application/json")
@@ -70,8 +78,19 @@
@Context
HttpServletRequest request)
{
- System.out.println("Remote user: " + request.getRemoteUser());
return new ProcessInstanceWrapper( processDAO.getInstanceByProcessDefinitionId(processId) );
}
+ @POST
+ @Path("instances/{id}/remove")
+ @Produces("application/json")
+ public ProcessInstanceWrapper removeInstancesJSON(
+ @PathParam("id")
+ long instanceId,
+ @Context
+ HttpServletRequest request)
+ {
+ return new ProcessInstanceWrapper( processDAO.removeProcessInstance(instanceId) );
+ }
+
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -35,7 +35,11 @@
{
List<ProcessDefinition> getAllProcessDefinitions();
- ProcessDefinition getProcessDefinitionById(long id);
+ ProcessDefinition getProcessDefinitionById(long processId);
- List<ProcessInstance> getInstanceByProcessDefinitionId(long id);
+ List<ProcessDefinition> removeProcessDefinition(long processId);
+
+ List<ProcessInstance> getInstanceByProcessDefinitionId(long processId);
+
+ List<ProcessInstance> removeProcessInstance(long instanceId);
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -48,7 +48,7 @@
defs.add( new ProcessDefinition(8, "Credit approval", "4"));
}
- final static List instances = new ArrayList();
+ final static List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
static
{
instances.add( new ProcessInstance(2, -1, "Running", new Date(), null));
@@ -78,8 +78,60 @@
return match;
}
+
+ public List<ProcessDefinition> removeProcessDefinition(long processId)
+ {
+ /*List<ProcessDefinition> updatedList = new ArrayList<ProcessDefinition>();
+ boolean match = false;
+ for(ProcessDefinition pd : defs)
+ {
+ if(processId != pd.getProcessId())
+ updatedList.add(pd);
+ else
+ match = true;
+ }
+
+ if(!match)
+ throw new IllegalArgumentException("No process with id " + processId);
+
+ return updatedList;*/
+
+ ProcessDefinition toBeRemoved = null;
+ for(ProcessDefinition pd : defs)
+ {
+ if(processId == pd.getProcessId())
+ toBeRemoved = pd;
+ }
+
+ if(null==toBeRemoved)
+ throw new IllegalArgumentException("No process with id " + processId);
+ else
+ defs.remove(toBeRemoved);
+
+ return defs;
+ }
+
public List<ProcessInstance> getInstanceByProcessDefinitionId(long id)
{
return instances;
}
+
+
+ public List<ProcessInstance> removeProcessInstance(long instanceId)
+ {
+ List<ProcessInstance> updatedList = new ArrayList<ProcessInstance>();
+ boolean match = false;
+ for(ProcessInstance i : instances)
+ {
+ if(instanceId != i.getId())
+ updatedList.add(i);
+ else
+ match = true;
+ }
+
+ if(!match)
+ throw new IllegalArgumentException("No instance with id " + instanceId);
+
+ return updatedList;
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-09 19:52:07 UTC (rev 2515)
@@ -21,24 +21,38 @@
<td>GET</td>
<td><a href="/gwt-console-server/rs/process/definitions">/rs/process/definitions</a></td>
<td>A list of process definitions</td>
- <td>application/json, text/html</td>
+ <td>application/json</td>
</tr>
<tr>
+ <td>POST</td>
+ <td>/rs/process/definitions/{processId}/remove</td>
+ <td>Removes a particular process definition</td>
+ <td>application/json</td>
+ </tr>
+
+ <tr>
<td>GET</td>
<td><a href="/gwt-console-server/rs/process/definitions/1/instances">/rs/process/definitions/{id}/instances</a></td>
<td>A list of process instances for a given process definition</td>
- <td>application/json, text/html</td>
+ <td>application/json</td>
</tr>
<tr>
- <td colspan=4>User Management</td>
+ <td>POST</td>
+ <td>/rs/process/instances/{instanceId}/remove</td>
+ <td>Removes a particular process instance</td>
+ <td>application/json</td>
</tr>
<tr>
+ <td colspan=4><h3>User Management</h3></td>
+ </tr>
+
+ <tr>
<td>GET</td>
<td><a href="/gwt-console-server/rs/user/roles?roleCheck=admin,user">/rs/user/roles?roleCheck=a,b,c</a></td>
- <td>A list of assigned roles</td>
+ <td>A list of assigned roles matching the query parameter (Comma seperated list)</td>
<td>application/json</td>
</tr>
</table>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -70,4 +70,14 @@
}
return consoleServerUrl + webContext + "/rs/user/roles?roleCheck="+sb.toString();
}
+
+ public String getRemoveDefinitionURL(long processId)
+ {
+ return consoleServerUrl + webContext + "/rs/process/definitions/" + processId + "/remove";
+ }
+
+ public String getRemoveInstanceURL(long instanceId)
+ {
+ return consoleServerUrl + webContext + "/rs/process/instances/" + instanceId + "/remove";
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -28,7 +28,6 @@
import com.gwtext.client.widgets.tree.TreeNode;
import com.gwtext.client.widgets.tree.TreePanel;
import com.gwtext.client.widgets.tree.event.TreeNodeListenerAdapter;
-import com.google.gwt.user.client.ui.HTML;
import org.jboss.bpm.console.client.metric.MetricOverviewEditor;
import org.jboss.bpm.console.client.process.ProcessDefinitionListEditor;
import org.jboss.bpm.console.client.widgets.MainMenuPanel;
@@ -157,7 +156,7 @@
StringBuffer sb = new StringBuffer();
for(String roleName : view.getRolesAssigned())
{
- sb.append(roleName).append("/");
+ sb.append("<br> - ").append(roleName);
}
view.displayMessage("Assigned roles: " + sb.toString(), false);
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -21,8 +21,10 @@
*/
package org.jboss.bpm.console.client.process;
+import com.google.gwt.http.client.*;
import com.gwtext.client.data.*;
-import com.gwtext.client.widgets.*;
+import com.gwtext.client.widgets.MessageBox;
+import com.gwtext.client.widgets.MessageBoxConfig;
import com.gwtext.client.widgets.grid.ColumnConfig;
import com.gwtext.client.widgets.grid.ColumnModel;
import org.jboss.bpm.console.client.ConsoleView;
@@ -37,7 +39,7 @@
*/
public class ProcessDefinitionList extends RemoteListView
{
- private Map row2ProcessMap = new HashMap();
+ private Map<Integer, ProcessDefinition> row2ProcessMap = new HashMap<Integer,ProcessDefinition>();
public ProcessDefinitionList(String titleName, final ConsoleView view)
{
@@ -75,13 +77,13 @@
final JsonReader reader = new JsonReader(recordDef);
reader.setRoot("definitions");
reader.setTotalProperty("totalCount");
- reader.setId("processId");
+ reader.setId("processId");
return reader;
}
protected void onExamine(int row)
{
- ProcessDefinition proc = (ProcessDefinition)row2ProcessMap.get(row);
+ ProcessDefinition proc = row2ProcessMap.get(row);
String editorId = ProcessInstanceEditor.ID+"."+proc.getName();
if(view.hasEditorView(editorId))
@@ -92,7 +94,6 @@
protected void onDelete(final int row)
{
- System.out.println("Delete " + row);
MessageBox.show(new MessageBoxConfig() {
{
setTitle("Delete process?");
@@ -102,9 +103,36 @@
setCallback(new MessageBox.PromptCallback() {
public void execute(String btnID, String text)
{
- // TODO: add delete operation
- ProcessDefinition proc = (ProcessDefinition)row2ProcessMap.get(row);
- System.out.println("Delete "+ proc +"? " + btnID);
+ if("yes".equals( btnID) )
+ {
+ ProcessDefinition proc = (ProcessDefinition)row2ProcessMap.get(row);
+ String url = view.getConfig().getRemoveDefinitionURL(proc.getProcessId());
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
+
+ try
+ {
+ rb.sendRequest("",
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ reloadStore();
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // auth failed
+ view.setError("Failed to remove process definition: "+t.getMessage());
+ t.printStackTrace(System.out);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ view.setError(e1.getMessage());
+ e1.printStackTrace();
+ }
+ }
}
});
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -21,7 +21,10 @@
*/
package org.jboss.bpm.console.client.process;
+import com.google.gwt.http.client.*;
import com.gwtext.client.data.*;
+import com.gwtext.client.widgets.MessageBox;
+import com.gwtext.client.widgets.MessageBoxConfig;
import com.gwtext.client.widgets.grid.ColumnConfig;
import com.gwtext.client.widgets.grid.ColumnModel;
import org.jboss.bpm.console.client.ConsoleView;
@@ -31,7 +34,6 @@
import java.util.HashMap;
import java.util.Map;
-import java.util.Date;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
@@ -39,7 +41,7 @@
public class ProcessInstanceList extends RemoteListView
{
- private Map row2InstanceMap = new HashMap();
+ private Map<Integer, ProcessInstance> row2InstanceMap = new HashMap<Integer, ProcessInstance>();
private ProcessDefinition parent;
private static final String DATE_FORMAT = "y-m-j H:i:s"; //08-10-02 13:51:27
@@ -56,7 +58,7 @@
protected void onExamine(final int row)
{
- ProcessInstance instance = (ProcessInstance)row2InstanceMap.get(row);
+ ProcessInstance instance = row2InstanceMap.get(row);
String id = ProcessInstanceEditor.ID+"."+instance.getId();
if(view.hasEditorView(id))
view.showEditor(id);
@@ -66,7 +68,48 @@
protected void onDelete(final int row)
{
- // TODO: Implement
+ MessageBox.show(new MessageBoxConfig() {
+ {
+ setTitle("Delete process instance?");
+ setMsg("Would you like to delete this process instance?");
+ setButtons(MessageBox.YESNOCANCEL);
+ setCallback(new MessageBox.PromptCallback() {
+ public void execute(String btnID, String text)
+ {
+ if("yes".equals( btnID) )
+ {
+ ProcessInstance instance = (ProcessInstance)row2InstanceMap.get(row);
+ String url = view.getConfig().getRemoveInstanceURL(instance.getId());
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
+
+ try
+ {
+ rb.sendRequest("",
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ reloadStore();
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // auth failed
+ view.setError("Failed to remove process instance: "+t.getMessage());
+ t.printStackTrace(System.out);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ view.setError(e1.getMessage());
+ e1.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+ });
}
protected void onRecordsLoaded(Record[] records)
@@ -76,7 +119,7 @@
{
Long id = Long.valueOf(r.getAsString("instanceId"));
ProcessInstance pd = new ProcessInstance(
- id,
+ id,
Long.valueOf( r.getAsString("parentId")),
r.getAsString("status"),
r.getAsDate("start"),
@@ -124,8 +167,8 @@
reader.setRoot("instances");
reader.setTotalProperty("totalCount");
reader.setId("instanceId");
-
- return reader;
+
+ return reader;
}
private static String getResourceUrl(ConsoleView view, long parentId)
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-09 06:47:55 UTC (rev 2514)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-09 19:52:07 UTC (rev 2515)
@@ -50,6 +50,8 @@
private GridPanel grid;
protected String title;
+ private Store store;
+
public RemoteListView(String titleName, ConsoleView view, String resourceUrl)
{
super();
@@ -83,7 +85,7 @@
DataProxy dataProxy = new ScriptTagProxy(resourceUrl, 1000*10);
- final Store store = new Store(dataProxy, reader, false); // boolean==remoteSort, add's GET parameters
+ store = new Store(dataProxy, reader, false); // boolean==remoteSort, add's GET parameters
store.addStoreListener( new ListViewStoreListener(this, grid) );
grid.setStore(store);
@@ -224,4 +226,9 @@
{
return grid;
}
+
+ protected void reloadStore()
+ {
+ store.load(0,PAGE_SIZE);
+ }
}
More information about the jbpm-commits
mailing list