[jbpm-commits] JBoss JBPM SVN: r5168 - in projects/gwt-console/trunk: gui/war/src/main/java/org/jboss/bpm/console/client/process and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jul 1 03:17:17 EDT 2009
Author: heiko.braun at jboss.com
Date: 2009-07-01 03:17:16 -0400 (Wed, 01 Jul 2009)
New Revision: 5168
Modified:
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/engine/ResourcePanel.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java
projects/gwt-console/trunk/server/server-integration/src/main/java/org/jboss/bpm/console/server/plugin/FormAuthorityRef.java
Log:
JBPM-2233: Start a process with task form
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/engine/ResourcePanel.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/engine/ResourcePanel.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/engine/ResourcePanel.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -96,6 +96,7 @@
initialize();
this.currentDeployment = null;
propGrid.clear();
+ resources.clear();
}
private DeploymentRef getSelection()
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -245,6 +245,8 @@
for(ProcessDefinitionRef def : definitions)
{
+ System.out.println("->"+def.getUrl());
+
if(FILTER_NONE==currentFilter)
{
model.add(def);
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -22,24 +22,27 @@
package org.jboss.bpm.console.client.process;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.WindowCloseListener;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.Widget;
import com.mvc4g.client.Controller;
import com.mvc4g.client.Event;
-import org.gwt.mosaic.ui.client.ListBox;
-import org.gwt.mosaic.ui.client.MessageBox;
-import org.gwt.mosaic.ui.client.ToolBar;
-import org.gwt.mosaic.ui.client.ToolButton;
+import org.gwt.mosaic.ui.client.*;
import org.gwt.mosaic.ui.client.layout.*;
import org.gwt.mosaic.ui.client.list.DefaultListModel;
+import org.jboss.bpm.console.client.ApplicationContext;
import org.jboss.bpm.console.client.common.AbstractView;
import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
import org.jboss.bpm.console.client.model.util.SimpleDateFormat;
-import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.util.ConsoleLog;
+import org.jboss.bpm.console.client.util.WindowUtil;
+import java.util.Date;
import java.util.List;
/**
@@ -65,11 +68,14 @@
private ApplicationContext appContext;
+ private WindowPanel windowPanel = null;
+ private Frame frame = null;
+
public InstanceListView(ApplicationContext appContext)
{
super();
this.appContext = appContext;
-
+
ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
setTitle("Process Instances");
setIcon(icons.instanceIcon());
@@ -105,7 +111,7 @@
listBox.setText(row, column, item.getState().toString());
break;
case 2:
- String d = item.getStartDate() != null ? dateFormat.format(item.getStartDate()) : "";
+ String d = item.getStartDate() != null ? dateFormat.format(item.getStartDate()) : "";
listBox.setText(row, column, d);
break;
default:
@@ -130,7 +136,7 @@
}
}
});
-
+
// toolbar
final LayoutPanel toolBox = new LayoutPanel();
toolBox.setPadding(0);
@@ -163,16 +169,25 @@
new MessageBox.ConfirmationCallback() {
public void onResult(boolean doIt)
{
-
if(doIt)
{
- controller.handleEvent(
- new Event(
- StartNewInstanceAction.ID,
- getCurrentDefinition()
- )
- );
+ String url = getCurrentDefinition().getUrl();
+ boolean hasForm = (url !=null && !url.equals(""));
+ if(hasForm)
+ {
+ createProcessFormWindow(getCurrentDefinition());
+ }
+ else
+ {
+ controller.handleEvent(
+ new Event(
+ StartNewInstanceAction.ID,
+ getCurrentDefinition()
+ )
+ );
+ }
}
+
}
});
@@ -276,11 +291,11 @@
layout.add(instanceList, new BorderLayoutData(BorderLayout.Region.CENTER));
// details
- InstanceDetailView detailsView = new InstanceDetailView(appContext);
+ InstanceDetailView detailsView = new InstanceDetailView(appContext);
controller.addView(InstanceDetailView.ID, detailsView);
-
+
controller.addAction(UpdateInstanceDetailAction.ID, new UpdateInstanceDetailAction());
-
+
layout.add(detailsView, new BorderLayoutData(BorderLayout.Region.SOUTH,10,200));
this.add(layout);
@@ -290,6 +305,62 @@
}
}
+ private void createProcessFormWindow(ProcessDefinitionRef process)
+ {
+ windowPanel = new WindowPanel("Process Interface");
+ windowPanel.setAnimationEnabled(true);
+ windowPanel.setSize("320px", "240px");
+
+ LayoutPanel layout = new LayoutPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+ layout.setStyleName("bpm-window-layout");
+ layout.setPadding(5);
+ // info
+ Label header = new Label("Process: "+process.getId());
+ header.setStyleName("bpm-label-header");
+ layout.add(header, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+
+ // task form iframe
+
+ windowPanel.addWindowCloseListener(new WindowCloseListener() {
+ public void onWindowClosed() {
+ controller.handleEvent(
+ new Event(UpdateInstancesAction.ID, getCurrentDefinition())
+ );
+
+ windowPanel = null;
+ frame = null;
+
+ }
+
+ public String onWindowClosing() {
+ return null;
+ }
+ });
+
+ // iframe
+ frame = new Frame();
+ DOM.setStyleAttribute(frame.getElement(), "border", "none");
+
+ // https://jira.jboss.org/jira/browse/JBPM-2244
+ frame.getElement().setId(
+ String.valueOf( new Date().getTime())
+ );
+
+ ConsoleLog.debug(frame.getElement().toString());
+ frame.setUrl(process.getUrl());
+
+ layout.add(frame, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+ windowPanel.setWidget(layout);
+
+ WindowUtil.addMaximizeButton(windowPanel, Caption.CaptionRegion.RIGHT);
+ WindowUtil.addMinimizeButton(windowPanel, Caption.CaptionRegion.RIGHT);
+
+ // display
+ windowPanel.center();
+
+ }
+
+
public ProcessInstanceRef getSelection()
{
ProcessInstanceRef selection = null;
Modified: projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -59,6 +59,12 @@
ProcessDefinitionRef ref = new ProcessDefinitionRef(id, name, version);
ref.setDeploymentId(dplId);
ref.setSuspended(isSuspended);
+
+ // optional start form url
+ JSONWalk.JSONWrapper url = JSONWalk.on(root).next("url");
+ if(url!=null)
+ ref.setUrl(url.asString());
+
return ref;
}
Modified: projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java
===================================================================
--- projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -40,6 +40,7 @@
private String deploymentId;
private boolean suspended;
+ private String url = null;
public ProcessDefinitionRef()
{
@@ -163,4 +164,14 @@
result = 31 * result + (key != null ? key.hashCode() : 0);
return result;
}
+
+ public void setUrl(String s)
+ {
+ this.url = s;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
}
Modified: projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java
===================================================================
--- projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -70,56 +70,102 @@
@GET
- @Path("task/{taskId}/render")
+ @Path("task/{id}/render")
@Produces("text/html")
public Response renderTaskUI(
- @PathParam("taskId")
+ @PathParam("id")
String taskId
)
{
- DataHandler dh = getFormDispatcherPlugin().provideForm(
- new FormAuthorityRef(taskId)
- );
+ return provideForm(new FormAuthorityRef(taskId));
+ }
- if(null==dh)
- {
- throw new RuntimeException("No UI associated with task ID " + taskId);
- }
-
- return Response.ok(dh.getDataSource()).type("text/html").build();
+ @GET
+ @Path("process/{id}/render")
+ @Produces("text/html")
+ public Response renderProcessUI(
+ @PathParam("id")
+ String definitionId
+ )
+ {
+ return provideForm(new FormAuthorityRef(definitionId, FormAuthorityRef.Type.PROCESS));
}
@POST
- @Path("task/{taskId}/complete")
+ @Path("task/{id}/complete")
@Produces("text/html")
@Consumes("multipart/form-data")
public Response closeTaskWithUI(
@Context
HttpServletRequest request,
- @PathParam("taskId")
+ @PathParam("id")
String taskId,
MultipartFormDataInput payload
)
{
+ Map<String,Object> processVars = createVariableMapping(payload);
+
+ // complete task
+ getFormDispatcherPlugin().processCompletion(
+ new FormAuthorityRef(taskId), processVars, request.getRemoteUser(), (String)processVars.get("outcome")
+ );
+
+ return Response.ok("Successfully processed input").build();
+ }
+
+ @POST
+ @Path("process/{id}/complete")
+ @Produces("text/html")
+ @Consumes("multipart/form-data")
+ public Response startProcessWithUI(
+ @Context
+ HttpServletRequest request,
+ @PathParam("id")
+ String definitionId,
+ MultipartFormDataInput payload
+ )
+ {
+ Map<String,Object> processVars = createVariableMapping(payload);
+
+ // complete task
+ FormAuthorityRef authref = new FormAuthorityRef(definitionId, FormAuthorityRef.Type.PROCESS);
+ getFormDispatcherPlugin().processCompletion(
+ authref, processVars, request.getRemoteUser(),
+ (String)processVars.get("outcome")
+ );
+
+ return Response.ok("Successfully processed input").build();
+ }
+
+ private Response provideForm(FormAuthorityRef authorityRef)
+ {
+ DataHandler dh = getFormDispatcherPlugin().provideForm(
+ authorityRef
+ );
+
+ if(null==dh)
+ {
+ throw new RuntimeException("No UI associated with "+authorityRef.getType()+" " + authorityRef.getReferenceId());
+ }
+
+ return Response.ok(dh.getDataSource()).type("text/html").build();
+ }
+
+ private Map<String, Object> createVariableMapping(MultipartFormDataInput payload)
+ {
Map<String,Object> processVars = new HashMap<String,Object>();
Map<String, InputPart> formData = payload.getFormData();
Iterator<String> partNames = formData.keySet().iterator();
- String outcome = null;
-
while(partNames.hasNext())
{
final String partName = partNames.next();
final InputPart part = formData.get(partName);
final MediaType mediaType = part.getMediaType();
- if(partName.equals("outcome"))
+ if(MediaType.TEXT_PLAIN_TYPE.equals(mediaType))
{
- outcome = part.getBodyAsString();
- }
- else if(MediaType.TEXT_PLAIN_TYPE.equals(mediaType))
- {
// RFC2045: Each part has an optional "Content-Type" header
// that defaults to "text/plain".
// Can go into process without conversion
@@ -158,11 +204,6 @@
}
}
- // complete task
- getFormDispatcherPlugin().processCompletion(
- new FormAuthorityRef(taskId), processVars, request.getRemoteUser(), outcome
- );
-
- return Response.ok("Successfully processed task UI").build();
+ return processVars;
}
}
Modified: projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
===================================================================
--- projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -28,21 +28,21 @@
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.bpm.console.client.model.ActiveNodeInfo;
-import org.jboss.bpm.console.client.model.ProcessDefinitionRefWrapper;
-import org.jboss.bpm.console.client.model.ProcessInstanceRef;
-import org.jboss.bpm.console.client.model.ProcessInstanceRefWrapper;
+import org.jboss.bpm.console.client.model.*;
import org.jboss.bpm.console.server.gson.GsonFactory;
import org.jboss.bpm.console.server.integration.ManagementFactory;
import org.jboss.bpm.console.server.integration.ProcessManagement;
+import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
+import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
+import org.jboss.bpm.console.server.plugin.GraphViewerPlugin;
import org.jboss.bpm.console.server.plugin.PluginMgr;
-import org.jboss.bpm.console.server.plugin.GraphViewerPlugin;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.io.InputStream;
+import java.net.URL;
import java.util.Iterator;
import java.util.List;
@@ -59,6 +59,22 @@
private ProcessManagement processManagement;
private GraphViewerPlugin graphViewerPlugin;
+ private FormDispatcherPlugin formPlugin;
+
+ /**
+ * Lazy load the {@link org.jboss.bpm.console.server.plugin.FormDispatcherPlugin}.
+ * Can be null if the plugin is not available.
+ */
+ private FormDispatcherPlugin getFormDispatcherPlugin()
+ {
+ if(null==this.formPlugin)
+ {
+ this.formPlugin = PluginMgr.load(FormDispatcherPlugin.class);
+ }
+
+ return this.formPlugin;
+ }
+
private ProcessManagement getProcessManagement()
{
if(null==this.processManagement)
@@ -88,8 +104,30 @@
@Produces("application/json")
public Response getDefinitionsJSON()
{
+ List<ProcessDefinitionRef> processDefinitions = getProcessManagement().getProcessDefinitions();
+ return decorateProcessDefintions(processDefinitions);
+ }
+
+ private Response decorateProcessDefintions( List<ProcessDefinitionRef> processDefinitions)
+ {
+ // decorate process form URL if plugin available
+ FormDispatcherPlugin formPlugin = getFormDispatcherPlugin();
+ if(formPlugin!=null)
+ {
+ for(ProcessDefinitionRef def : processDefinitions)
+ {
+ URL processFormURL = formPlugin.getDispatchUrl(
+ new FormAuthorityRef(def.getId(), FormAuthorityRef.Type.PROCESS)
+ );
+ if(processFormURL!=null)
+ {
+ def.setUrl(processFormURL.toExternalForm());
+ }
+ }
+ }
+
ProcessDefinitionRefWrapper wrapper =
- new ProcessDefinitionRefWrapper(getProcessManagement().getProcessDefinitions());
+ new ProcessDefinitionRefWrapper(processDefinitions);
return createJsonResponse(wrapper);
}
@@ -134,7 +172,7 @@
return createJsonResponse(instance);
}
catch (Throwable t)
- {
+ {
throw new WebApplicationException(t, 500);
}
@@ -176,7 +214,7 @@
public Response deleteInstance(
@PathParam("id")
String executionId
- )
+ )
{
log.debug("Delete instance (ID "+executionId+")");
getProcessManagement().deleteInstance(executionId);
@@ -278,7 +316,7 @@
GraphViewerPlugin plugin = getProcessGraphViewPlugin();
if(plugin !=null)
{
- return Response.ok(plugin.getProcessImage(id)).type("image/png").build();
+ return Response.ok(plugin.getProcessImage(id)).type("image/png").build();
}
throw new RuntimeException(
Modified: projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java
===================================================================
--- projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -73,7 +73,7 @@
* Lazy load the {@link org.jboss.bpm.console.server.plugin.FormDispatcherPlugin}.
* Can be null if the plugin is not available.
*/
- private FormDispatcherPlugin getTaskDispatcherPlugin()
+ private FormDispatcherPlugin getFormDispatcherPlugin()
{
if(null==this.formPlugin)
{
@@ -110,7 +110,7 @@
private Response processTaskListResponse(List<TaskRef> taskList)
{
// decorate task form URL if plugin available
- FormDispatcherPlugin formPlugin = getTaskDispatcherPlugin();
+ FormDispatcherPlugin formPlugin = getFormDispatcherPlugin();
if(formPlugin!=null)
{
for(TaskRef task : taskList)
Modified: projects/gwt-console/trunk/server/server-integration/src/main/java/org/jboss/bpm/console/server/plugin/FormAuthorityRef.java
===================================================================
--- projects/gwt-console/trunk/server/server-integration/src/main/java/org/jboss/bpm/console/server/plugin/FormAuthorityRef.java 2009-07-01 07:13:50 UTC (rev 5167)
+++ projects/gwt-console/trunk/server/server-integration/src/main/java/org/jboss/bpm/console/server/plugin/FormAuthorityRef.java 2009-07-01 07:17:16 UTC (rev 5168)
@@ -41,7 +41,7 @@
this.currentType = Type.TASK;
}
- public FormAuthorityRef(Type currentType, String referenceId)
+ public FormAuthorityRef(String referenceId, Type currentType)
{
this.currentType = currentType;
this.referenceId = referenceId;
More information about the jbpm-commits
mailing list