[jbpm-commits] JBoss JBPM SVN: r4571 - in projects/gwt-console/branches/hbraun: plugin-api/src/main/java/org/jboss/bpm/console/client/model and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Apr 16 15:32:13 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-04-16 15:32:12 -0400 (Thu, 16 Apr 2009)
New Revision: 4571

Added:
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java
Removed:
   projects/gwt-console/branches/hbraun/war/src/test/java/org/jboss/bpm/console/client/GwtTestProcessManagement.java
Modified:
   projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java
   projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java
Log:
First cut of the instance list view

Modified: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java	2009-04-16 19:28:20 UTC (rev 4570)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/Editor.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -50,7 +50,7 @@
 
     // hmvc controller chain.
     this.controller = new Controller();
-    this.controller.setParent(appContext.getController());
+    this.controller.setParent(appContext.getController());        
   }
 
   public abstract String getEditorId();

Modified: projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java	2009-04-16 19:28:20 UTC (rev 4570)
+++ projects/gwt-console/branches/hbraun/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -178,8 +178,20 @@
     return p;
   }
 
-  public static ProcessInstanceRef parseProcessInstance(JSONObject root)
+  public static List<ProcessInstanceRef> parseProcessInstances(JavaScriptObject jso)
   {
+    List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
+
+    JSONArray arr = JSONWalk.on( new JSONObject(jso)).next("instances").asArray();
+    for(int i=0; i<arr.size(); i++)
+    {
+      results.add(parseProcessInstance(arr.get(i)));
+    }
+    return results;
+  }
+
+  public static ProcessInstanceRef parseProcessInstance(JSONValue root)
+  {
     ConsoleLog.debug("parse " + root);
 
     //  {"id":"StateSequence/8", "definitionId":"StateSequence:1",
@@ -268,4 +280,5 @@
 
     return result;
   }
+
 }

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java	2009-04-16 19:28:20 UTC (rev 4570)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/MainLayout.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -34,6 +34,7 @@
 import org.gwt.mosaic.ui.client.layout.BorderLayoutData;
 import org.gwt.mosaic.ui.client.layout.LayoutPanel;
 import org.jboss.bpm.console.client.*;
+import org.jboss.bpm.console.client.v2.process.ProcessEditor;
 
 /**
  * The main composite that assembles the gwt console application.
@@ -73,7 +74,7 @@
 
     LayoutPanel layout = createLayout();
     viewport.add(layout);
-
+    
     RootPanel.get().add(viewport);
   }
 

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java	2009-04-16 19:28:20 UTC (rev 4570)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -23,15 +23,13 @@
 
 import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.client.ui.Button;
 import com.mvc4g.client.Controller;
 import com.mvc4g.client.Event;
 import com.mvc4g.client.ViewInterface;
 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.MessageBox;
-import org.gwt.mosaic.ui.client.util.ButtonHelper;
 import org.gwt.mosaic.ui.client.layout.BoxLayout;
 import org.gwt.mosaic.ui.client.layout.BoxLayoutData;
 import org.gwt.mosaic.ui.client.layout.LayoutPanel;
@@ -45,36 +43,30 @@
  */
 public class DefinitionListView extends LayoutPanel implements ViewInterface
 {
+  public final static String ID = DefinitionListView.class.getName();
+
   private Controller controller;
 
-  private LayoutPanel table = null;
+  private LayoutPanel definitionList = null;
 
-  public final static String ID = DefinitionListView.class.getName();
+  private ListBox<ProcessDefinitionRef> listBox;
 
   public DefinitionListView()
   {
     super();
     setTitle("Process Definitions");
-  }
 
-  public void setController(Controller controller)
-  {
-    this.controller = controller;
-  }
+    definitionList = new LayoutPanel( new BoxLayout(BoxLayout.Orientation.VERTICAL));
+    definitionList.setPadding(0);
+    definitionList.setWidgetSpacing(0);
 
-  private LayoutPanel createTable(List<ProcessDefinitionRef> definitions)
-  {
-    final LayoutPanel vBox = new LayoutPanel( new BoxLayout(BoxLayout.Orientation.VERTICAL));
-    vBox.setPadding(0);
-    vBox.setWidgetSpacing(0);
-
-    final ListBox<ProcessDefinitionRef> listBox =
+    listBox =
         new ListBox<ProcessDefinitionRef>(
             new String[] {
                 "Process ID", "Name", "Key", "Version"}
         );
 
-    
+
     listBox.setCellRenderer(new ListBox.CellRenderer<ProcessDefinitionRef>() {
       public void renderCell(ListBox<ProcessDefinitionRef> listBox, int row, int column,
                              ProcessDefinitionRef item) {
@@ -100,18 +92,13 @@
     final DefaultListModel<ProcessDefinitionRef> model =
         (DefaultListModel<ProcessDefinitionRef>) listBox.getModel();
 
-    for(ProcessDefinitionRef def : definitions)
-    {
-      model.add(def);
-    }    
-    
     // toolbar
 
     final LayoutPanel toolBox = new LayoutPanel();
     toolBox.setPadding(0);
     toolBox.setWidgetSpacing(5);
     //toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
-    
+
     final ToolBar toolBar = new ToolBar();
     toolBar.add(
         new ToolButton("Refresh", new ClickListener() {
@@ -134,7 +121,12 @@
             if(index==-1)
               MessageBox.alert("Missing selection", "Please select a process");
             else
-              System.out.println(index);
+              controller.handleEvent(
+                  new Event(
+                      LoadInstancesAction.ID,
+                      listBox.getItem( listBox.getSelectedIndex())
+                  )
+              );
           }
         }
         )
@@ -142,19 +134,28 @@
 
     toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
 
-    vBox.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
-    vBox.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+    this.definitionList.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+    this.definitionList.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
 
-    return vBox;
+    this.add(definitionList);
   }
 
+  public void setController(Controller controller)
+  {
+    this.controller = controller;
+  }
+
   public void update(List<ProcessDefinitionRef> definitions)
   {
-    if(this.table!=null)
-      this.remove(table);
+    final DefaultListModel<ProcessDefinitionRef> model =
+        (DefaultListModel<ProcessDefinitionRef>) listBox.getModel();
 
-    this.table = createTable(definitions);
-    this.add(table);
+    model.clear();
+    
+    for(ProcessDefinitionRef def : definitions)
+    {
+      model.add(def);
+    }
 
     // layout again
     this.invalidate();

Added: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java	                        (rev 0)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.v2.process;
+
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Widget;
+import com.mvc4g.client.Controller;
+import com.mvc4g.client.ViewInterface;
+import com.mvc4g.client.Event;
+import org.gwt.mosaic.ui.client.ListBox;
+import org.gwt.mosaic.ui.client.ToolBar;
+import org.gwt.mosaic.ui.client.ToolButton;
+import org.gwt.mosaic.ui.client.layout.BoxLayout;
+import org.gwt.mosaic.ui.client.layout.BoxLayoutData;
+import org.gwt.mosaic.ui.client.layout.LayoutPanel;
+import org.gwt.mosaic.ui.client.list.DefaultListModel;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class InstanceListView extends LayoutPanel implements ViewInterface
+{
+  public final static String ID = InstanceListView.class.getName();
+
+  private Controller controller;
+
+  private LayoutPanel instanceList = null;
+
+  private ListBox<ProcessInstanceRef> listBox;
+
+  private ProcessDefinitionRef currentDefinition;
+
+  public InstanceListView()
+  {
+    super();
+    setTitle("Process Instances");
+
+    instanceList = new LayoutPanel( new BoxLayout(BoxLayout.Orientation.VERTICAL));
+    instanceList.setPadding(0);
+    instanceList.setWidgetSpacing(0);
+
+    listBox =
+        new ListBox<ProcessInstanceRef>(
+            new String[] {
+                "Instance ID", "State", "Start Date"}
+        );
+
+
+    listBox.setCellRenderer(new ListBox.CellRenderer<ProcessInstanceRef>() {
+      public void renderCell(ListBox<ProcessInstanceRef> listBox, int row, int column,
+                             ProcessInstanceRef item) {
+        switch (column) {
+          case 0:
+            listBox.setText(row, column, item.getId());
+            break;
+          case 1:
+            listBox.setText(row, column, item.getState().toString());
+            break;
+          case 2:
+            listBox.setText(row, column, item.getStartDate().toString());
+            break;
+          default:
+            throw new RuntimeException("Unexpected column size");
+        }
+      }
+    });
+
+    // toolbar
+
+    final LayoutPanel toolBox = new LayoutPanel();
+    toolBox.setPadding(0);
+    toolBox.setWidgetSpacing(5);
+    //toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+
+    final ToolBar toolBar = new ToolBar();
+    toolBar.add(
+        new ToolButton("Refresh", new ClickListener() {
+          public void onClick(Widget sender) {
+            controller.handleEvent(
+                new Event(
+                    LoadInstancesAction.ID,
+                    getCurrentDefinition()
+                )
+            );
+          }
+        }
+        )
+    );
+
+    toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+
+    instanceList.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+    instanceList.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+
+    this.add(instanceList);
+  }
+
+  private ProcessDefinitionRef getCurrentDefinition()
+  {
+    return this.currentDefinition;
+  }
+
+  public void setController(Controller controller)
+  {
+    this.controller = controller;
+  }
+
+
+  public void update(final ProcessDefinitionRef def, List<ProcessInstanceRef> instances)
+  {    
+    this.currentDefinition = def;
+
+    final DefaultListModel<ProcessInstanceRef> model =
+        (DefaultListModel<ProcessInstanceRef>) listBox.getModel();
+    model.clear();
+    
+    for(ProcessInstanceRef inst : instances)
+    {
+      model.add(inst);
+    }
+    
+    // layout again
+    this.invalidate();
+  }
+}

Added: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java	                        (rev 0)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.v2.process;
+
+import com.mvc4g.client.ActionInterface;
+import com.mvc4g.client.Controller;
+import com.google.gwt.core.client.JavaScriptObject;
+import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.DTOParser;
+import org.jboss.bpm.console.client.util.JSONRequest;
+import org.jboss.bpm.console.client.util.JSONRequestHandler;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class LoadInstancesAction implements ActionInterface
+{
+
+  public final static String ID = LoadInstancesAction.class.getName();
+
+  private ApplicationContext appContext;
+
+  public LoadInstancesAction(ApplicationContext appContext)
+  {
+    this.appContext = appContext;
+  }
+
+  public void execute(final Controller controller, Object object)
+  {
+    final ProcessDefinitionRef def = (ProcessDefinitionRef)object;
+
+    String url = appContext.getUrlBuilder().getProcessInstancesURL(def.getId());
+
+    JSONRequest.get(
+        url, new JSONRequestHandler()
+    {
+      public void onRequestComplete(JavaScriptObject json)
+      {
+        if (json == null) {
+          appContext.displayMessage("Couldn't retrieve process instance data", true);
+          return;
+        }
+
+        List<ProcessInstanceRef> instances = null;
+        try
+        {
+          instances = DTOParser.parseProcessInstances(json);
+        }
+        catch (Throwable e)
+        {
+          e.printStackTrace();
+          appContext.displayMessage(e.getMessage(), true);
+        }
+
+
+        InstanceListView view = (InstanceListView) controller.getView(InstanceListView.ID);
+        view.update(def, instances);
+
+        appContext.displayMessage("Loaded " + instances.size() + " process instances", false);
+      }
+    }
+    );
+  }
+}

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java	2009-04-16 19:28:20 UTC (rev 4570)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -53,9 +53,11 @@
 
     // create and register views
     addView(DefinitionListView.ID, new DefinitionListView());
-
+    addView(InstanceListView.ID, new InstanceListView());
+    
     // create and register actions
     addAction(LoadDefinitionsAction.ID, new LoadDefinitionsAction(appContext));
+    addAction(LoadInstancesAction.ID, new LoadInstancesAction(appContext));
 
     // force loading
     super.controller.handleEvent(
@@ -63,6 +65,7 @@
     );
 
     tabPanel.selectTab(0);
+            
   }
 
   private void addView(String id, Widget view)

Deleted: projects/gwt-console/branches/hbraun/war/src/test/java/org/jboss/bpm/console/client/GwtTestProcessManagement.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/test/java/org/jboss/bpm/console/client/GwtTestProcessManagement.java	2009-04-16 19:28:20 UTC (rev 4570)
+++ projects/gwt-console/branches/hbraun/war/src/test/java/org/jboss/bpm/console/client/GwtTestProcessManagement.java	2009-04-16 19:32:12 UTC (rev 4571)
@@ -1,278 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.console.client;
-
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.Response;
-import com.gwtext.client.widgets.ComponentMgr;
-import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
-import org.jboss.bpm.console.client.process.ProcessDefinitionList;
-import org.jboss.bpm.console.client.process.ProcessEditor;
-import org.jboss.bpm.console.client.process.ProcessInstanceListView;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class GwtTestProcessManagement extends AbstractConsoleTC
-{
-   public void testProcessManagement()
-   {
-      System.out.println("=== testProcessInstanceEditor ===");
-
-      final ProcessEditor editor = (ProcessEditor)
-            ComponentMgr.getComponent(ProcessEditor.ID);
-      
-      Map<String, Object> context = new HashMap<String, Object>();
-      context.put("editor", editor);
-
-      DeployTestHarnessTimer deployTimer = new DeployTestHarnessTimer(context);
-      AuthenticationTimer authTimer = new AuthenticationTimer(context,"admin", "admin");
-      LoadTestHarnessTimer loadingTimer = new LoadTestHarnessTimer(context);
-      InstanceEditorTimer instanceTimer = new InstanceEditorTimer(context);
-      UndeployTimer undeployTimer = new UndeployTimer(context);
-
-      context.put("deployFollow", authTimer);
-      context.put("authFollow", loadingTimer);
-      context.put("loadFollow", instanceTimer);
-      context.put("instanceFollow", undeployTimer);
-      
-      // trigger first timer
-      deployTimer.schedule(1000);
-      delayTestFinish(2000);
-
-   }
-
-   class DeployTestHarnessTimer extends ChainedTimer
-   {
-
-      protected DeployTestHarnessTimer(Map<String, Object> context)
-      {
-         super(context);
-      }
-
-      public void run()
-      {
-         String url = urlBuilder.getDeployTestHarnessUrl();
-         RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
-         try
-         {
-            rb.sendRequest("",
-                  new RequestCallback()
-                  {
-
-                     public void onResponseReceived(Request request, Response response)
-                     {
-                        if(response.getStatusCode()!=200)
-                           throw new RuntimeException("HTTP status " + response.getStatusCode());
-
-                        proceedOrFinish();
-                     }
-
-                     public void onError(Request request, Throwable t)
-                     {
-                        throw new RuntimeException("Connection problem", t);
-                     }
-                  }
-            ); 
-         }
-         catch (Throwable e)
-         {
-            throw new RuntimeException("Failed to remove process definition", e);
-         }
-      }
-
-      public ChainedTimer getNext()
-      {
-         return (ChainedTimer)context.get("deployFollow");
-      }
-   }
-   class LoadTestHarnessTimer extends ChainedTimer
-   {
-
-      public LoadTestHarnessTimer(Map<String, Object> context)
-      {
-         super(context);
-      }
-
-      public ChainedTimer getNext()
-      {
-         return (ChainedTimer)context.get("loadFollow");
-      }
-
-      public void run()
-      {
-         ProcessEditor editor = (ProcessEditor) context.get("editor");
-         editor.resetEditor();
-         ProcessDefinitionList list = editor.getProcessDefinitionList();
-         proceedOrFinish();
-      }
-   }
-
-   class InstanceEditorTimer extends ChainedTimer
-   {
-      public InstanceEditorTimer(Map<String, Object> context)
-      {
-         super(context);      
-      }
-
-
-      public ChainedTimer getNext()
-      {
-         return (ChainedTimer)context.get("instanceFollow");
-      }
-
-      public void run()
-      {
-         ProcessEditor editor = (ProcessEditor)context.get("editor");
-         ProcessDefinitionList list = editor.getProcessDefinitionList();
-
-         List<ProcessDefinitionRef> processDefinitions = list.getAvailableProcessDefinitions();
-         ProcessDefinitionRef testPd = getTestProcessDefinition(processDefinitions);
-         assertNotNull("No test definition given: " +processDefinitions, testPd);
-
-         list.launchInstanceView(testPd);  // will create an instance editor
-
-         // lookup instance editor
-         String editorId = ProcessInstanceListView.createWidgetID(testPd);
-         ProcessInstanceListView instanceView = (ProcessInstanceListView)
-               ComponentMgr.getComponent(editorId);
-         assertNotNull("Failed to create instance editor for process", instanceView);
-
-         // todo: start new instance
-         System.out.println("FIXME: Implement instance creation test");
-
-         List<ProcessDefinitionRef> defs = list.getAvailableProcessDefinitions();
-         assertFalse(defs.isEmpty());
-
-         proceedOrFinish();
-      }
-   }
-
-   private ProcessDefinitionRef getTestProcessDefinition(List<ProcessDefinitionRef> list)
-   {
-      ProcessDefinitionRef def =null;
-      for(ProcessDefinitionRef pd : list)
-      {
-         if(pd.getName().equals(GWT_TEST_HARNESS))
-         {
-            def=pd;
-            break;
-         }
-      }
-      return def;
-   }
-
-   class UndeployTimer extends ChainedTimer
-   {
-      public UndeployTimer(Map<String, Object> context)
-      {
-         super(context);         
-      }
-
-      public ChainedTimer getNext()
-      {
-         return (ChainedTimer)context.get("undeployFollow");  
-      }
-
-      public void run()
-      {
-         String deleteUrl = urlBuilder.getUndeployTestHarnessUrl();
-         RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, deleteUrl);
-         try
-         {
-
-            rb.sendRequest("",
-                  new RequestCallback()
-                  {
-
-                     public void onResponseReceived(Request request, Response response)
-                     {
-                        if(response.getStatusCode()!=200)
-                           throw new RuntimeException("HTTP status " + response.getStatusCode());
-                     }
-
-                     public void onError(Request request, Throwable t)
-                     {
-                        throw new RuntimeException("Connection problem", t);
-                     }
-                  }
-            ); 
-         }
-         catch (Throwable e)
-         {
-            throw new RuntimeException("Failed to remove process definition", e);
-         }
-
-         proceedOrFinish();
-      }
-   }
-
-   class AuthenticationTimer extends ChainedTimer
-   {
-      String user;
-      String pass;
-
-      public AuthenticationTimer(Map<String,Object> context, String user, String pass)
-      {
-         super(context);
-         
-         this.user = user;
-         this.pass = pass;
-      }
-
-
-      public ChainedTimer getNext()
-      {
-         return (ChainedTimer)context.get("authFollow");  
-      }
-
-      public void run()
-      {
-
-         String inRoleURL = urlBuilder.getUserInRoleURL(Application.KNOWN_ROLES);
-         final Authentication auth = new Authentication(inRoleURL);
-         auth.setCallback(
-               new Authentication.AuthCallback() {
-
-                  public void onLoginSuccess(Request request, Response response) {
-                     System.out.println("Assigned roles: " + auth.getRolesAssigned() );                     
-
-                     // only proceed when authentication was successfull
-                     proceedOrFinish();
-                  }
-
-                  public void onLoginFailed(Request request, Throwable t) {
-
-                     throw new RuntimeException("Login failed", t);
-                  }
-               }
-         );
-         auth.doLogin(user,pass);
-      }
-   }
-}




More information about the jbpm-commits mailing list