[jbpm-commits] JBoss JBPM SVN: r2579 - in jbpm3/trunk/modules/gwt-console/war: src and 10 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Oct 22 09:07:30 EDT 2008
Author: heiko.braun at jboss.com
Date: 2008-10-22 09:07:30 -0400 (Wed, 22 Oct 2008)
New Revision: 2579
Added:
jbpm3/trunk/modules/gwt-console/war/GWT_TEST_README.txt
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Authentication.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
jbpm3/trunk/modules/gwt-console/war/src/test/
jbpm3/trunk/modules/gwt-console/war/src/test/java/
jbpm3/trunk/modules/gwt-console/war/src/test/java/BlankTest.java
jbpm3/trunk/modules/gwt-console/war/src/test/java/org/
jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/
jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/
jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/console/
jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/console/client/
jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/console/client/GwtTestApplication.java
jbpm3/trunk/modules/gwt-console/war/src/test/resources/
Removed:
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
Modified:
jbpm3/trunk/modules/gwt-console/war/pom.xml
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Application.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/EditorPanel.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/ProcessDefinitionListEditor.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
Log:
GwtTest sample, first cut. begin refactoring towards better testability
Added: jbpm3/trunk/modules/gwt-console/war/GWT_TEST_README.txt
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/GWT_TEST_README.txt (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/GWT_TEST_README.txt 2008-10-22 13:07:30 UTC (rev 2579)
@@ -0,0 +1,12 @@
+Special node for executing GWT tests under linux:
+The GWT-maven plugin executes any test prefixed "GwtTest"
+(See http://gwt-maven.googlecode.com/svn/docs/maven-googlewebtoolkit2-plugin/testing.html)
+It reads stderr in order to figure wether or not the test has been successful.
+On fedora (or any other linux) it happens that that mozilla components issue the following
+INFO message to stderr, which causes the test to fail:
+
+> Gtk-WARNING **: Unable to locate theme engine in module_path: "nodoka"
+
+This is caused by missing nodoka (theme) package; please install it as follow:
+yum install gtk-nodoka-engine (on fedora)
+
Property changes on: jbpm3/trunk/modules/gwt-console/war/GWT_TEST_README.txt
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/war/pom.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/pom.xml 2008-10-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/pom.xml 2008-10-22 13:07:30 UTC (rev 2579)
@@ -98,7 +98,7 @@
<goal>mergewebxml</goal>
<goal>compile</goal>
<goal>gwt</goal>
- <!--goal>test</goal-->
+ <goal>test</goal>
</goals>
</execution>
</executions>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Application.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Application.java 2008-10-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Application.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -7,12 +7,18 @@
*/
public class Application implements EntryPoint
{
+ private ConsoleView consoleView;
+
/**
* This is the entry point method.
*/
public void onModuleLoad()
{
- ConsoleView consoleView = new ConsoleView();
+ consoleView = new ConsoleView();
}
+ public ConsoleView getConsoleView()
+ {
+ return consoleView;
+ }
}
Added: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Authentication.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Authentication.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Authentication.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -0,0 +1,122 @@
+/*
+ * 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.*;
+import org.jboss.bpm.console.client.model.DTOParser;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class Authentication
+{
+ private String loginUrl;
+ private AuthCallback callback;
+ private List<String> rolesAssigned = new ArrayList<String>();
+
+
+ public Authentication(String loginUrl)
+ {
+ this.loginUrl = loginUrl;
+ }
+
+ public Authentication(String loginUrl, AuthCallback callback)
+ {
+ this.loginUrl = loginUrl;
+ this.callback = callback;
+ }
+
+ /**
+ * Login, but leave credentials to GWT.
+ * This will pop up a username/password dialog netive to the browser.
+ */
+ public void doLogin()
+ {
+ doLogin(null,null);
+ }
+
+ /**
+ * Login using specific credentials.
+ * This delegates to {@link com.google.gwt.http.client.RequestBuilder#setUser(String)}
+ * and {@link com.google.gwt.http.client.RequestBuilder#setPassword(String)}
+ */
+ public void doLogin(String user, String pass)
+ {
+
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, loginUrl);
+
+ if(user!=null&&pass!=null)
+ {
+ rb.setUser(user);
+ rb.setPassword(pass);
+ }
+
+ try
+ {
+ rb.sendRequest(null,
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ // parse roles
+ rolesAssigned = DTOParser.parseRolesAssigned(response.getText());
+ if(callback!=null) callback.onLoginSuccess(request, response);
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // auth failed
+ if(callback!=null)
+ callback.onLoginFailed(request, t);
+ else
+ throw new RuntimeException("Login failed", t);
+ }
+ });
+ }
+
+ catch (RequestException e1)
+ {
+ throw new RuntimeException("Unknown error upon login attempt", e1);
+ }
+ }
+
+
+ public void setCallback(AuthCallback callback)
+ {
+ this.callback = callback;
+ }
+
+ public interface AuthCallback
+ {
+ void onLoginSuccess(Request request, Response response);
+ void onLoginFailed(Request request, Throwable t);
+ }
+
+
+ public List<String> getRolesAssigned()
+ {
+ return rolesAssigned;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Authentication.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java 2008-10-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -22,11 +22,8 @@
package org.jboss.bpm.console.client;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.*;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONValue;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.gwtext.client.core.EventObject;
@@ -43,9 +40,6 @@
import org.jboss.bpm.console.client.widgets.EditorView;
import org.jboss.bpm.console.client.widgets.UIConstants;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* The main composite that assembles the gwt console application.
*
@@ -57,16 +51,16 @@
private HeaderPanel header;
private MainMenu mainMenu;
private EditorPanel editorPanel;
- private RestURL restURL = new RestURL( "http://localhost:8080", "gwt-console-server");
+ private URLBuilder URLBuilder = new URLBuilder( "http://localhost:8080", "gwt-console-server");
private String[] rolesAssigned = new String[] {};
- private final static String[] POSSIBLE_ROLES = {"admin", "user"};
-
+ public final static String[] KNOWN_ROLES = {"admin", "user"};
+
private static final int WIDTH = 1024;
private static final int HEIGHT = 768;
private Viewport viewport;
-
+
public ConsoleView()
{
Panel mainPanel = createMainPanel();
@@ -131,13 +125,13 @@
panel.setStyleName("login-panel-content");
panel.setLayout(new VerticalLayout(10));
panel.add( new HTML("Welcome, please login.") );
-
+
final Window window = new Window();
window.setTitle("GWT-Console");
window.setClosable(false);
- window.setResizable(false);
+ window.setResizable(false);
window.setWidth(300);
- window.setHeight(180);
+ window.setHeight(180);
window.setLayout(new BorderLayout());
window.setCloseAction(Window.CLOSE);
@@ -149,62 +143,39 @@
if(GWT.isScript())
{
- String url = getRestURL().getUserInRoleURL(POSSIBLE_ROLES);
- RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
+ String url = getRestURL().getUserInRoleURL(KNOWN_ROLES);
+ final Authentication authentication = new Authentication(url);
+ authentication.setCallback(
+ new Authentication.AuthCallback()
+ {
- try
- {
- rb.sendRequest(null,
- new RequestCallback() {
+ public void onLoginSuccess(Request request, Response response)
+ {
+ // parse roles
+ rolesAssigned = authentication.getRolesAssigned().toArray(new String[] {});
- public void onResponseReceived(Request request, Response response)
- {
- // parse roles
- List<String> tmp = new ArrayList<String>();
+ // display main console
+ window.close();
+ mainPanel.show();
+ mainPanel.doLayout();
+ }
- JSONValue result = JSONParser.parse(response.getText());
- JSONValue jsonValue = result.isObject().get("roles");
- JSONArray array = jsonValue.isArray();
- for (int i = 0; i < array.size(); ++i)
- {
- JSONObject item = array.get(i).isObject();
- String assigned = item.get("assigned").toString();
- String roleName = item.get("role").toString();
+ public void onLoginFailed(Request request, Throwable t)
+ {
+ // auth failed
+ setError("Authentication failed.");
+ t.printStackTrace(System.out);
+ }
+ }
+ );
-
- if(assigned.equals("true"))
- {
- tmp.add(roleName);
- }
-
- }
-
- rolesAssigned = tmp.toArray(new String[] {});
-
- window.close();
- mainPanel.show();
- mainPanel.doLayout();
- }
-
- public void onError(Request request, Throwable t)
- {
- // auth failed
- setError("Authentication failed.");
- t.printStackTrace(System.out);
- }
- });
- }
- catch (RequestException e1)
- {
- setError(e1.getMessage());
- e1.printStackTrace();
- }
+ authentication.doLogin();
}
else
{
// hosted mode roles grant any role
// will popup BASIC Auth windows when required
- rolesAssigned = POSSIBLE_ROLES;
+ rolesAssigned = KNOWN_ROLES;
window.close();
mainPanel.show();
@@ -235,9 +206,9 @@
return editorPanel.hasEditor(id);
}
- public RestURL getRestURL()
+ public URLBuilder getRestURL()
{
- return restURL;
+ return URLBuilder;
}
public void showEditor(String id)
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/EditorPanel.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/EditorPanel.java 2008-10-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/EditorPanel.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -83,7 +83,7 @@
}
return b;
- }
+ }
public void showTab(String id)
{
Deleted: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -1,112 +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 org.jboss.bpm.console.client.model.ProcessInstance;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class RestURL
-{
- private final String consoleServerUrl;
- private final String webContext;
-
- public RestURL(String consoleServerUrl, String webContext)
- {
- this.consoleServerUrl = consoleServerUrl;
- this.webContext = webContext;
- }
-
- public String getConsoleServerUrl()
- {
- return consoleServerUrl;
- }
-
- public String getWebContext()
- {
- return webContext;
- }
-
- private String getBaseUrl()
- {
- return consoleServerUrl + "/" + webContext;
- }
-
- public String getProcessDefinitionURL()
- {
- return getBaseUrl() + "/rs/process/definitions";
- }
-
- public String getProcessInstanceURL(long processId)
- {
- return getBaseUrl() + "/rs/process/definitions/"+processId+"/instances";
- }
-
- public String getUserInRoleURL(String[] possibleRoles)
- {
- StringBuffer sb = new StringBuffer();
- for(int i=0; i<possibleRoles.length; i++)
- {
- sb.append(possibleRoles[i]);
- if(i<possibleRoles.length-1)
- sb.append(",");
- }
- return getBaseUrl() + "/rs/user/roles?roleCheck="+sb.toString();
- }
-
- @Deprecated
- public String getRemoveDefinitionURL(long processId)
- {
- return getBaseUrl() + "/rs/process/definitions/" + processId + "/remove";
- }
-
- public String getProcessImageURL(long processId)
- {
- return getBaseUrl() + "/rs/jbpm3/definitions/" + processId + "/image";
- }
-
- public String getDiagramInfoURL(long processId)
- {
- return getBaseUrl() + "/rs/jbpm3/definitions/" + processId + "/diagramInfo";
- }
-
- public String getActiveNodeInfoURL(long instanceId)
- {
- return getBaseUrl() + "/rs/jbpm3/instances/" + instanceId + "/activeNodeInfo";
- }
-
- public String getStateChangeURL(long instanceId, ProcessInstance.STATE state)
- {
- return getBaseUrl() + "/rs/process/instances/" + instanceId + "/state/"+state;
- }
-
- public String getStartNewInstanceURL(long processId)
- {
- return getBaseUrl() + "/rs/process/definitions/"+processId+"/instances/new";
- }
-
- public String getUploadDefinitionURL()
- {
- return getBaseUrl() + "/rs/jbpm3/definitions/new";
- }
-}
Added: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -0,0 +1,112 @@
+/*
+ * 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 org.jboss.bpm.console.client.model.ProcessInstance;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class URLBuilder
+{
+ private final String consoleServerUrl;
+ private final String webContext;
+
+ public URLBuilder(String consoleServerUrl, String webContext)
+ {
+ this.consoleServerUrl = consoleServerUrl;
+ this.webContext = webContext;
+ }
+
+ public String getConsoleServerUrl()
+ {
+ return consoleServerUrl;
+ }
+
+ public String getWebContext()
+ {
+ return webContext;
+ }
+
+ private String getBaseUrl()
+ {
+ return consoleServerUrl + "/" + webContext;
+ }
+
+ public String getProcessDefinitionURL()
+ {
+ return getBaseUrl() + "/rs/process/definitions";
+ }
+
+ public String getProcessInstanceURL(long processId)
+ {
+ return getBaseUrl() + "/rs/process/definitions/"+processId+"/instances";
+ }
+
+ public String getUserInRoleURL(String[] possibleRoles)
+ {
+ StringBuffer sb = new StringBuffer();
+ for(int i=0; i<possibleRoles.length; i++)
+ {
+ sb.append(possibleRoles[i]);
+ if(i<possibleRoles.length-1)
+ sb.append(",");
+ }
+ return getBaseUrl() + "/rs/user/roles?roleCheck="+sb.toString();
+ }
+
+ @Deprecated
+ public String getRemoveDefinitionURL(long processId)
+ {
+ return getBaseUrl() + "/rs/process/definitions/" + processId + "/remove";
+ }
+
+ public String getProcessImageURL(long processId)
+ {
+ return getBaseUrl() + "/rs/jbpm3/definitions/" + processId + "/image";
+ }
+
+ public String getDiagramInfoURL(long processId)
+ {
+ return getBaseUrl() + "/rs/jbpm3/definitions/" + processId + "/diagramInfo";
+ }
+
+ public String getActiveNodeInfoURL(long instanceId)
+ {
+ return getBaseUrl() + "/rs/jbpm3/instances/" + instanceId + "/activeNodeInfo";
+ }
+
+ public String getStateChangeURL(long instanceId, ProcessInstance.STATE state)
+ {
+ return getBaseUrl() + "/rs/process/instances/" + instanceId + "/state/"+state;
+ }
+
+ public String getStartNewInstanceURL(long processId)
+ {
+ return getBaseUrl() + "/rs/process/definitions/"+processId+"/instances/new";
+ }
+
+ public String getUploadDefinitionURL()
+ {
+ return getBaseUrl() + "/rs/jbpm3/definitions/new";
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -0,0 +1,61 @@
+/*
+ * 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.model;
+
+import com.google.gwt.json.client.JSONValue;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class DTOParser
+{
+ public static List<String> parseRolesAssigned(String json)
+ {
+ // parse roles
+ List<String> roles = new ArrayList<String>();
+
+ JSONValue result = JSONParser.parse(json);
+ JSONValue jsonValue = result.isObject().get("roles");
+ JSONArray array = jsonValue.isArray();
+ for (int i = 0; i < array.size(); ++i)
+ {
+ JSONObject item = array.get(i).isObject();
+ String assigned = item.get("assigned").toString();
+ String roleName = item.get("role").toString();
+
+
+ if(assigned.equals("true"))
+ {
+ roles.add(roleName);
+ }
+
+ }
+
+ return roles;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -31,8 +31,7 @@
import org.jboss.bpm.console.client.model.ProcessDefinition;
import org.jboss.bpm.console.client.widgets.RemoteListView;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
@@ -163,5 +162,17 @@
System.out.println("Loaded " + row2ProcessMap.size() + " records");
}
+
+ public List<ProcessDefinition> getAvailableProcessDefinitions()
+ {
+ List<ProcessDefinition> results = new ArrayList<ProcessDefinition>();
+ Iterator<Integer> keys = row2ProcessMap.keySet().iterator();
+ while(keys.hasNext())
+ {
+ results.add(row2ProcessMap.get(keys.next()));
+ }
+
+ return results;
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionListEditor.java 2008-10-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionListEditor.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -49,7 +49,7 @@
{
public final static String ID = "org.jboss.bpm.process.ProcessList";
- private ProcessDefinitionList processDefinitions;
+ private ProcessDefinitionList processDefinitionList;
private ConsoleView view;
@@ -72,7 +72,7 @@
leftHand.setHeader(false);
leftHand.setBorder(false);
- processDefinitions = new ProcessDefinitionList("Process Definitions", view);
+ processDefinitionList = new ProcessDefinitionList("Process Definitions", view);
// ----------------------------------
@@ -120,7 +120,7 @@
public void onActionComplete(Form form, int i, String string)
{
- processDefinitions.reloadStore();
+ processDefinitionList.reloadStore();
leftHand.doLayout();
form.reset();
}
@@ -201,7 +201,7 @@
// ----------------------------------
- leftHand.add(processDefinitions);
+ leftHand.add(processDefinitionList);
leftHand.add(outerFormPanel);
this.add(leftHand, new ColumnLayoutData(0.7) );
@@ -227,4 +227,9 @@
{
return "bpm-process-icon";
}
+
+ public ProcessDefinitionList getProcessDefinitionList()
+ {
+ return processDefinitionList;
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-22 03:19:19 UTC (rev 2578)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -217,7 +217,7 @@
public void onResponseReceived(Request request, Response response)
{
- // success
+ // testSuccess
instanceList.reloadStore();
selectedInstance = null;
}
Added: jbpm3/trunk/modules/gwt-console/war/src/test/java/BlankTest.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/test/java/BlankTest.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/src/test/java/BlankTest.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class BlankTest extends TestCase
+{
+ public void testSuccess()
+ {
+ Assert.assertTrue(true);
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/test/java/BlankTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/console/client/GwtTestApplication.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/console/client/GwtTestApplication.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/console/client/GwtTestApplication.java 2008-10-22 13:07:30 UTC (rev 2579)
@@ -0,0 +1,83 @@
+/*
+ * 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.junit.client.GWTTestCase;
+import com.gwtext.client.widgets.ComponentMgr;
+import org.jboss.bpm.console.client.process.ProcessDefinitionListEditor;
+import org.jboss.bpm.console.client.process.ProcessDefinitionList;
+import org.jboss.bpm.console.client.model.ProcessDefinition;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class GwtTestApplication extends GWTTestCase
+{
+
+ private static Application application = null;
+
+ public String getModuleName()
+ {
+ return "org.jboss.bpm.console.Application";
+ }
+
+
+ protected void gwtSetUp() throws Exception
+ {
+ super.gwtSetUp();
+ if(null==application)
+ {
+ application = new Application();
+ application.onModuleLoad();
+
+ /*URLBuilder urlBuilder = new URLBuilder("localhost:8080", "gwt-console-server");
+ Authentication auth = new Authentication(urlBuilder.getUserInRoleURL(ConsoleView.KNOWN_ROLES));
+ auth.doLogin("admin", "admin");
+ System.out.println("Assigned roles: " + auth.getRolesAssigned() );*/
+ }
+
+ }
+
+ public void testInitialisation()
+ {
+ ConsoleView view = application.getConsoleView();
+ assertNotNull("View not initialized", view);
+
+ /*ProcessDefinitionListEditor procListEditor =
+ (ProcessDefinitionListEditor)ComponentMgr.getComponent(ProcessDefinitionListEditor.ID);
+ assertNotNull("ProcessDefinitionListEditor not initialized", procListEditor);
+
+ // load process definitions
+ ProcessDefinitionList procDefList = procListEditor.getProcessDefinitionList();
+ procDefList.reloadStore();
+
+ List<ProcessDefinition> available = procDefList.getAvailableProcessDefinitions();
+ assertFalse("No process definitions available", available.isEmpty());
+
+ for(ProcessDefinition def : available)
+ {
+ System.out.println(def);
+ } */
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/test/java/org/jboss/bpm/console/client/GwtTestApplication.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jbpm-commits
mailing list