[jbpm-commits] JBoss JBPM SVN: r2996 - in projects/gwt-console/trunk: server/src/main/java/org/jboss/bpm/console/server/dao and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Nov 19 08:04:27 EST 2008
Author: heiko.braun at jboss.com
Date: 2008-11-19 08:04:27 -0500 (Wed, 19 Nov 2008)
New Revision: 2996
Added:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3MgmtFacade.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/InvocationProxy.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/JBPM3Extension.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ManagementFactory.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/UserManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementExtension.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementFactory.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3UserManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMembershipCommand.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetUsersForGroupCommand.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/BufferedResponseWrapper.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/FilterServletOutputStream.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/GWTJsonFilter.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentCallback.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentFormPanel.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/DetailsFormPanel.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/FormWidgets.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelChangeListener.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelListenerRegistry.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/RefreshableComboBox.java
Removed:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/FilterServletOutputStream.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ExtensionDAO.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskDAO.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ExtensionDAO.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskDAO.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMemershipCommand.java
Modified:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/web.xml
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/UIConstants.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenEditor.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenForm.java
Log:
Refactor TaskManagement to support model listener. Change DAO interfaces to Management interfaces
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,76 +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.server;
-
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at SuppressWarnings("deprecation")
-public class BufferedResponseWrapper extends HttpServletResponseWrapper
-{
- private ByteArrayOutputStream output;
- private int contentLength;
- private String contentType = "";
-
- public BufferedResponseWrapper(HttpServletResponse httpServletResponse)
- {
- super(httpServletResponse);
- output=new ByteArrayOutputStream();
- }
-
- public byte[] getData() {
- return output.toByteArray();
- }
-
- public ServletOutputStream getOutputStream() {
- return new FilterServletOutputStream(output);
- }
-
- public PrintWriter getWriter() {
- return new PrintWriter(getOutputStream(),true);
- }
-
- public void setContentLength(int length) {
- this.contentLength = length;
- super.setContentLength(length);
- }
-
- public int getContentLength() {
- return contentLength;
- }
-
- public void setContentType(String type) {
- this.contentType = type;
- super.setContentType(type);
- }
-
- public String getContentType() {
- return contentType;
- }
-}
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -21,7 +21,7 @@
*/
package org.jboss.bpm.console.server;
-import org.jboss.bpm.console.server.JBPM3Management;
+import org.jboss.bpm.console.server.JBPM3MgmtFacade;
import javax.ws.rs.core.Application;
import java.util.HashSet;
@@ -36,10 +36,10 @@
public ConsoleServerApplication()
{
- singletons.add(new ProcessManagement());
- singletons.add(new TaskManagement());
- singletons.add(new UserManagement());
- singletons.add(new JBPM3Management());
+ singletons.add(new ProcessMgmtFacade());
+ singletons.add(new TaskMgmtFacade());
+ singletons.add(new UserMgmtFacade());
+ singletons.add(new JBPM3MgmtFacade());
}
@Override
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/FilterServletOutputStream.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/FilterServletOutputStream.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/FilterServletOutputStream.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,54 +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.server;
-
-import javax.servlet.ServletOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class FilterServletOutputStream extends ServletOutputStream
-{
-
- private DataOutputStream stream;
-
- public FilterServletOutputStream(OutputStream output) {
- stream = new DataOutputStream(output);
- }
-
- public void write(int b) throws IOException {
- stream.write(b);
- }
-
- public void write(byte[] b) throws IOException {
- stream.write(b);
- }
-
- public void write(byte[] b, int off, int len) throws IOException
- {
- stream.write(b,off,len);
- }
-
-}
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -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.server;
-
-import javax.servlet.*;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class GWTJsonFilter implements Filter
-{
-
- public FilterConfig filterConfig;
- private static final String COLLECTION_PREFIX = "{\"wrapper\":";
- private static final String COLLECTION_SUFFIX = "}";
-
- public void init(FilterConfig filterConfig) throws ServletException
- {
- this.filterConfig = filterConfig;
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws IOException, ServletException
- {
-
- boolean isSOPCallback = false;
-
- // identify GWT json requests
- if(request.getParameter("callback")!=null)
- isSOPCallback = true;
-
- // sneak in repsonse wrapper
- OutputStream out = response.getOutputStream();
- BufferedResponseWrapper wrapper = new BufferedResponseWrapper((HttpServletResponse) response);
-
- // proceed chain
- chain.doFilter(request, wrapper);
-
- // add callback std. json output
- String contentType = response.getContentType() != null ? response.getContentType() : "application/octet-stream";
- boolean isJSONEncoding = contentType.equals("application/json");
- StringBuffer sb = null;
- if(isJSONEncoding)
- {
- String payload = new String(wrapper.getData());
- String gwtextFriendly = trimPayload(payload);
-
- sb = new StringBuffer();
-
- if(isSOPCallback)
- {
- sb.append(request.getParameter("callback"));
- sb.append("(");
- }
-
- // Strip wrapper when JSONRequest
- sb.append(gwtextFriendly);
-
- if(isSOPCallback)
- {
- sb.append(");");
- }
-
- }
-
- // flush
- if(sb!=null)
- out.write(sb.toString().getBytes());
- else
- out.write(wrapper.getData());
-
- out.flush();
- out.close();
- }
-
- private String trimPayload(String payload)
- {
- String s = payload;
- if(s.startsWith(COLLECTION_PREFIX))
- {
- s = payload.substring( COLLECTION_PREFIX.length(), payload.lastIndexOf(COLLECTION_SUFFIX));
- }
- return s;
- }
-
- public void destroy()
- {
-
- }
-}
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,200 +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.server;
-
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileItemFactory;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-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.jbpm3.ActiveNodeInfo;
-import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
-import org.jboss.bpm.console.server.dao.DAOFactory;
-import org.jboss.bpm.console.server.dao.ExtensionDAO;
-import org.jboss.bpm.console.server.dao.ProcessDAO;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at Path("jbpm3")
-public class JBPM3Management
-{
- private static final Log log = LogFactory.getLog(JBPM3Management.class);
-
- private ExtensionDAO extensionDAO = null;
- private ProcessDAO processDAO = null;
-
- private ProcessDAO getProcessDAO()
- {
- if(null==this.processDAO)
- {
- DAOFactory factory = DAOFactory.newInstance();
- this.processDAO = factory.createProcessDAO();
- log.debug("Using DAOFactory impl:" + factory.getClass().getName());
- }
-
- return this.processDAO;
-
- }
-
- private ExtensionDAO getExtensionDAO()
- {
- if(null==this.extensionDAO)
- {
- DAOFactory factory = DAOFactory.newInstance();
- this.extensionDAO = factory.createDiagramDAO();
- }
-
- return this.extensionDAO;
-
- }
-
- @POST
- @Path("definitions/new")
- @Produces("application/json")
- @Consumes("multipart/form-data")
- public Response postNewDefinition(
- @Context
- HttpServletRequest request
- )
- {
- try
- {
- FileItemFactory factory = new DiskFileItemFactory();
- ServletFileUpload upload = new ServletFileUpload(factory);
- List items = upload.parseRequest(request);
-
- Iterator iter = items.iterator();
- while (iter.hasNext())
- {
- FileItem item = (FileItem) iter.next();
-
- if (item.isFormField())
- {
- // ignore
- log.debug("Caught form field on file upload: " + item.getName());
- }
- else
- {
- String fieldName = item.getFieldName();
- String fileName = item.getName();
- String contentType = item.getContentType();
- boolean isInMemory = item.isInMemory();
- long sizeInBytes = item.getSize();
-
- // Process a file upload in memory
- byte[] data = item.get();
-
- getProcessDAO().deployNewDefinition(data);
-
- // Process stream
- //InputStream uploadedStream = item.getInputStream();
- //uploadedStream.close();
-
- }
-
-
- }
- } catch (Throwable e)
- {
- throw new WebApplicationException(e);
- }
-
- return Response.ok().build();
-
- }
-
- @GET
- @Path("definitions/{id}/image")
- @Produces("image/jpeg")
- public Response getProcessImage(
- @PathParam("id")
- long id
- )
- {
- byte[] image = getExtensionDAO().getProcessImage(id);
- if(null==image)
- return Response.serverError().build();
- else
- return Response.ok(image).type("image/jpeg").build();
- }
-
- @GET
- @Path("definitions/{id}/diagramInfo")
- @Produces("application/json")
- public DiagramInfo getDiagramInfo(
- @PathParam("id")
- long id
- )
- {
- return getExtensionDAO().getDiagramInfo(id);
- }
-
- @GET
- @Path("instances/{id}/activeNodeInfo")
- @Produces("application/json")
- public ActiveNodeInfo getActiveNodeInfo(
- @PathParam("id")
- long id
- )
- {
- ActiveNodeInfo activNodeInfo = getExtensionDAO().getActivNodeInfo(id);
- return activNodeInfo;
- }
-
- @POST
- @Path("tokens/{id}/transition")
- @Produces("application/json")
- public Response signalToken(
- @PathParam("id")
- long id,
- @QueryParam("signal")
- String signalName)
- {
- log.debug("Signal token " + id + " -> " + signalName);
-
- getExtensionDAO().signalToken(id, signalName);
- return Response.ok().type("application/json").build();
- }
-
- @POST
- @Path("tokens/{id}/transition/default")
- @Produces("application/json")
- public Response signalTokenDefault(
- @PathParam("id")
- long id)
- {
- log.debug("Signal token " + id);
-
- getExtensionDAO().signalToken(id, null);
- return Response.ok().type("application/json").build();
- }
-
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3MgmtFacade.java (from rev 2909, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3MgmtFacade.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3MgmtFacade.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,200 @@
+/*
+ * 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.server;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+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.jbpm3.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.server.dao.ManagementFactory;
+import org.jboss.bpm.console.server.dao.JBPM3Extension;
+import org.jboss.bpm.console.server.dao.ProcessManagement;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("jbpm3")
+public class JBPM3MgmtFacade
+{
+ private static final Log log = LogFactory.getLog(JBPM3MgmtFacade.class);
+
+ private JBPM3Extension JBPM3Extension = null;
+ private ProcessManagement processManagement = null;
+
+ private ProcessManagement getProcessDAO()
+ {
+ if(null==this.processManagement)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.processManagement = factory.createProcessManagement();
+ log.debug("Using ManagementFactory impl:" + factory.getClass().getName());
+ }
+
+ return this.processManagement;
+
+ }
+
+ private JBPM3Extension getExtensionDAO()
+ {
+ if(null==this.JBPM3Extension)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.JBPM3Extension = factory.createExtensionManagement();
+ }
+
+ return this.JBPM3Extension;
+
+ }
+
+ @POST
+ @Path("definitions/new")
+ @Produces("application/json")
+ @Consumes("multipart/form-data")
+ public Response postNewDefinition(
+ @Context
+ HttpServletRequest request
+ )
+ {
+ try
+ {
+ FileItemFactory factory = new DiskFileItemFactory();
+ ServletFileUpload upload = new ServletFileUpload(factory);
+ List items = upload.parseRequest(request);
+
+ Iterator iter = items.iterator();
+ while (iter.hasNext())
+ {
+ FileItem item = (FileItem) iter.next();
+
+ if (item.isFormField())
+ {
+ // ignore
+ log.debug("Caught form field on file upload: " + item.getName());
+ }
+ else
+ {
+ String fieldName = item.getFieldName();
+ String fileName = item.getName();
+ String contentType = item.getContentType();
+ boolean isInMemory = item.isInMemory();
+ long sizeInBytes = item.getSize();
+
+ // Process a file upload in memory
+ byte[] data = item.get();
+
+ getProcessDAO().deployNewDefinition(data);
+
+ // Process stream
+ //InputStream uploadedStream = item.getInputStream();
+ //uploadedStream.close();
+
+ }
+
+
+ }
+ } catch (Throwable e)
+ {
+ throw new WebApplicationException(e);
+ }
+
+ return Response.ok().build();
+
+ }
+
+ @GET
+ @Path("definitions/{id}/image")
+ @Produces("image/jpeg")
+ public Response getProcessImage(
+ @PathParam("id")
+ long id
+ )
+ {
+ byte[] image = getExtensionDAO().getProcessImage(id);
+ if(null==image)
+ return Response.serverError().build();
+ else
+ return Response.ok(image).type("image/jpeg").build();
+ }
+
+ @GET
+ @Path("definitions/{id}/diagramInfo")
+ @Produces("application/json")
+ public DiagramInfo getDiagramInfo(
+ @PathParam("id")
+ long id
+ )
+ {
+ return getExtensionDAO().getDiagramInfo(id);
+ }
+
+ @GET
+ @Path("instances/{id}/activeNodeInfo")
+ @Produces("application/json")
+ public ActiveNodeInfo getActiveNodeInfo(
+ @PathParam("id")
+ long id
+ )
+ {
+ ActiveNodeInfo activNodeInfo = getExtensionDAO().getActivNodeInfo(id);
+ return activNodeInfo;
+ }
+
+ @POST
+ @Path("tokens/{id}/transition")
+ @Produces("application/json")
+ public Response signalToken(
+ @PathParam("id")
+ long id,
+ @QueryParam("signal")
+ String signalName)
+ {
+ log.debug("Signal token " + id + " -> " + signalName);
+
+ getExtensionDAO().signalToken(id, signalName);
+ return Response.ok().type("application/json").build();
+ }
+
+ @POST
+ @Path("tokens/{id}/transition/default")
+ @Produces("application/json")
+ public Response signalTokenDefault(
+ @PathParam("id")
+ long id)
+ {
+ log.debug("Signal token " + id);
+
+ getExtensionDAO().signalToken(id, null);
+ return Response.ok().type("application/json").build();
+ }
+
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/JBPM3MgmtFacade.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,137 +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.server;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.jboss.bpm.console.client.model.ProcessDefinitionWrapper;
-import org.jboss.bpm.console.client.model.ProcessInstanceWrapper;
-import org.jboss.bpm.console.client.model.ProcessInstance;
-import org.jboss.bpm.console.server.dao.DAOFactory;
-import org.jboss.bpm.console.server.dao.ProcessDAO;
-import org.jboss.bpm.console.server.gson.GsonFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-
-/**
- * REST server module for accessing process related data.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at Path("process")
-public class ProcessManagement
-{
-
- private static final Log log = LogFactory.getLog(ProcessManagement.class);
-
- private ProcessDAO processDAO;
-
- /**
- * Lazy load the {@link org.jboss.bpm.console.server.dao.ProcessDAO}
- */
- private ProcessDAO getProcessDAO()
- {
- if(null==this.processDAO)
- {
- DAOFactory factory = DAOFactory.newInstance();
- this.processDAO = factory.createProcessDAO();
- log.debug("Using DAOFactory impl:" + factory.getClass().getName());
- }
-
- return this.processDAO;
- }
-
- @GET
- @Path("definitions")
- @Produces("application/json")
- public Response getDefinitionsJSON()
- {
- ProcessDefinitionWrapper wrapper =
- new ProcessDefinitionWrapper(getProcessDAO().getAllDefinitions());
- return createJsonResponse(wrapper);
- }
-
- @POST
- @Path("definitions/{id}/remove")
- @Produces("application/json")
- public Response removeDefinitionsJSON(
- @PathParam("id")
- long processId
- )
- {
- ProcessDefinitionWrapper wrapper =
- new ProcessDefinitionWrapper( getProcessDAO().removeDefinition(processId));
- return createJsonResponse(wrapper);
- }
-
- @GET
- @Path("definitions/{id}/instances")
- @Produces("application/json")
- public Response getInstancesJSON(
- @PathParam("id")
- long processId
- )
- {
-
- ProcessInstanceWrapper wrapper =
- new ProcessInstanceWrapper(getProcessDAO().getInstancesByProcessId(processId));
- return createJsonResponse(wrapper);
- }
-
- @POST
- @Path("definitions/{id}/instances/new")
- @Produces("application/json")
- public Response newInstance(
- @PathParam("id")
- long processId)
- {
-
- ProcessInstance instance = getProcessDAO().newInstance(processId);
- return createJsonResponse(instance);
- }
-
- @POST
- @Path("instances/{id}/state/{next}")
- @Produces("application/json")
- public Response changeState(
- @PathParam("id")
- long instanceId,
- @PathParam("next")
- String next)
- {
- log.debug("Change instance (ID "+instanceId+") to state " +next);
- getProcessDAO().changeState(instanceId, next);
- return Response.ok().type("application/json").build();
- }
-
- private Response createJsonResponse(Object wrapper)
- {
- Gson gson = GsonFactory.createInstance();
- String json = gson.toJson(wrapper);
- return Response.ok(json).type("application/json").build();
- }
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java (from rev 2905, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,134 @@
+/*
+ * 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.server;
+
+import com.google.gson.Gson;
+import org.jboss.bpm.console.client.model.ProcessDefinitionWrapper;
+import org.jboss.bpm.console.client.model.ProcessInstanceWrapper;
+import org.jboss.bpm.console.client.model.ProcessInstance;
+import org.jboss.bpm.console.server.dao.ManagementFactory;
+import org.jboss.bpm.console.server.dao.ProcessManagement;
+import org.jboss.bpm.console.server.gson.GsonFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+
+/**
+ * REST server module for accessing process related data.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("process")
+public class ProcessMgmtFacade
+{
+
+ private static final Log log = LogFactory.getLog(ProcessMgmtFacade.class);
+
+ private ProcessManagement processManagement;
+
+ /**
+ * Lazy load the {@link org.jboss.bpm.console.server.dao.ProcessManagement}
+ */
+ private ProcessManagement getProcessDAO()
+ {
+ if(null==this.processManagement)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.processManagement = factory.createProcessManagement();
+ log.debug("Using ManagementFactory impl:" + factory.getClass().getName());
+ }
+
+ return this.processManagement;
+ }
+
+ @GET
+ @Path("definitions")
+ @Produces("application/json")
+ public Response getDefinitionsJSON()
+ {
+ ProcessDefinitionWrapper wrapper =
+ new ProcessDefinitionWrapper(getProcessDAO().getAllDefinitions());
+ return createJsonResponse(wrapper);
+ }
+
+ @POST
+ @Path("definitions/{id}/remove")
+ @Produces("application/json")
+ public Response removeDefinitionsJSON(
+ @PathParam("id")
+ long processId
+ )
+ {
+ ProcessDefinitionWrapper wrapper =
+ new ProcessDefinitionWrapper( getProcessDAO().removeDefinition(processId));
+ return createJsonResponse(wrapper);
+ }
+
+ @GET
+ @Path("definitions/{id}/instances")
+ @Produces("application/json")
+ public Response getInstancesJSON(
+ @PathParam("id")
+ long processId
+ )
+ {
+
+ ProcessInstanceWrapper wrapper =
+ new ProcessInstanceWrapper(getProcessDAO().getInstancesByProcessId(processId));
+ return createJsonResponse(wrapper);
+ }
+
+ @POST
+ @Path("definitions/{id}/instances/new")
+ @Produces("application/json")
+ public Response newInstance(
+ @PathParam("id")
+ long processId)
+ {
+
+ ProcessInstance instance = getProcessDAO().newInstance(processId);
+ return createJsonResponse(instance);
+ }
+
+ @POST
+ @Path("instances/{id}/state/{next}")
+ @Produces("application/json")
+ public Response changeState(
+ @PathParam("id")
+ long instanceId,
+ @PathParam("next")
+ String next)
+ {
+ log.debug("Change instance (ID "+instanceId+") to state " +next);
+ getProcessDAO().changeState(instanceId, next);
+ return Response.ok().type("application/json").build();
+ }
+
+ private Response createJsonResponse(Object wrapper)
+ {
+ Gson gson = GsonFactory.createInstance();
+ String json = gson.toJson(wrapper);
+ return Response.ok(json).type("application/json").build();
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,207 +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.server;
-
-import com.google.gson.Gson;
-import org.jboss.bpm.console.client.model.TaskReferenceWrapper;
-import org.jboss.bpm.console.client.model.TaskReference;
-import org.jboss.bpm.console.client.model.forms.FieldDef;
-import org.jboss.bpm.console.client.model.forms.FormDef;
-import org.jboss.bpm.console.client.model.util.MapEntry;
-import org.jboss.bpm.console.server.dao.DAOFactory;
-import org.jboss.bpm.console.server.dao.TaskDAO;
-import org.jboss.bpm.console.server.dao.internal.JBPM3FormParser;
-import org.jboss.bpm.console.server.gson.GsonFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Response;
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * REST server module for accessing task related data.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at Path("tasks")
-public class TaskManagement
-{
- private static final Log log = LogFactory.getLog(TaskManagement.class);
-
- private TaskDAO taskDAO;
-
- /**
- * Lazy load the {@link org.jboss.bpm.console.server.dao.ProcessDAO}
- */
- private TaskDAO getTaskDAO()
- {
- if(null==this.taskDAO)
- {
- DAOFactory factory = DAOFactory.newInstance();
- this.taskDAO = factory.createTaskDAO();
- log.debug("Using DAOFactory impl:" + factory.getClass().getName());
- }
-
- return this.taskDAO;
- }
-
- @GET
- @Path("actor/{actorName}")
- @Produces("application/json")
- public Response getTasksForActor(
- @PathParam("actorName")
- String actorName
- )
- {
- TaskReferenceWrapper wrapper =
- new TaskReferenceWrapper(getTaskDAO().getTasksByActor(actorName));
- return createJsonResponse(wrapper);
- }
-
- @GET
- @Path("forms/{processId}")
- @Produces("application/json")
- public Response getTasksForms(
- @PathParam("processId")
- long processId
- )
- {
- Map<String,String> formMapping =
- getTaskDAO().getAvailableTaskForms(processId);
-
- List<MapEntry> entries = new ArrayList<MapEntry>();
- for(String s : formMapping.keySet())
- {
- entries.add( new MapEntry(s, formMapping.get(s)) );
- }
-
- return createJsonResponse( entries );
- }
-
- @POST
- @Path("{taskId}/assignment/{actorId}")
- @Produces("application/json")
- public Response assignTask(
- @PathParam("taskId")
- long taskId,
- @PathParam("actorId")
- String actorId
- )
- {
- log.debug("Reassign task " + taskId + " to '" + actorId +"'");
- getTaskDAO().reassignTask(taskId, actorId);
- return Response.ok().build();
- }
-
- @POST
- @Path("{taskId}/assignment")
- @Produces("application/json")
- public Response releaseTask(
- @PathParam("taskId")
- long taskId
- )
- {
- log.debug("Release task " + taskId);
- getTaskDAO().reassignTask(taskId, null);
- return Response.ok().build();
- }
-
- @POST
- @Path("{taskId}/close/transition/default")
- @Produces("application/json")
- public Response closeTask(
- @PathParam("taskId")
- long taskId
- )
- {
- return closeTaskWithSignal(taskId, null);
- }
-
- @POST
- @Path("{taskId}/close/transition")
- @Produces("application/json")
- public Response closeTaskWithSignal(
- @PathParam("taskId")
- long taskId,
- @QueryParam("signal")
- String signalName
- )
- {
- log.debug("Close task " + taskId);
- getTaskDAO().closeTask(taskId, signalName);
- return Response.ok().build();
- }
-
-
- @GET
- @Path("forms/{processId}/{taskId}")
- @Produces("application/json")
- public Response getTasksFormByTaskId(
- @PathParam("processId")
- long processId,
- @PathParam("taskId")
- long taskId
-
- )
- {
- byte[] form = getTaskDAO().getTaskFormByTaskName(processId, taskId);
- JBPM3FormParser parser = new JBPM3FormParser();
- final FormDef formDef = new FormDef("taskform-"+taskId);
- try
- {
- parser.parse( new ByteArrayInputStream(form));
-
- parser.visitResults(
- new JBPM3FormParser.ParseResultVisitor()
- {
-
- public void onInputField(FieldDef field)
- {
- formDef.getFields().add(field);
- }
-
- public void onInputButton(JBPM3FormParser.InputButton btn)
- {
- // TODO: parse buttons
- }
- }
- );
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to parse form data", e);
- }
-
- return createJsonResponse(formDef);
- }
-
- private Response createJsonResponse(Object wrapper)
- {
- Gson gson = GsonFactory.createInstance();
- String json = gson.toJson(wrapper);
- return Response.ok(json).type("application/json").build();
- }
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java (from rev 2962, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskManagement.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,220 @@
+/*
+ * 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.server;
+
+import com.google.gson.Gson;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.console.client.model.TaskReferenceWrapper;
+import org.jboss.bpm.console.client.model.forms.FieldDef;
+import org.jboss.bpm.console.client.model.forms.FormDef;
+import org.jboss.bpm.console.client.model.util.MapEntry;
+import org.jboss.bpm.console.server.dao.ManagementFactory;
+import org.jboss.bpm.console.server.dao.JBPM3Extension;
+import org.jboss.bpm.console.server.dao.TaskManagement;
+import org.jboss.bpm.console.server.dao.internal.JBPM3FormParser;
+import org.jboss.bpm.console.server.gson.GsonFactory;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * REST server module for accessing task related data.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("tasks")
+public class TaskMgmtFacade
+{
+ private static final Log log = LogFactory.getLog(TaskMgmtFacade.class);
+
+ private TaskManagement taskManagement;
+ private JBPM3Extension JBPM3Extension;
+
+ /**
+ * Lazy load the {@link org.jboss.bpm.console.server.dao.ProcessManagement}
+ */
+ private TaskManagement getTaskDAO()
+ {
+ if(null==this.taskManagement)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.taskManagement = factory.createTaskManagement();
+ log.debug("Using ManagementFactory impl:" + factory.getClass().getName());
+ }
+
+ return this.taskManagement;
+ }
+
+ private JBPM3Extension getExtensionDAO()
+ {
+ if(null==this.JBPM3Extension)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.JBPM3Extension = factory.createExtensionManagement();
+ }
+
+ return this.JBPM3Extension;
+
+ }
+
+ @GET
+ @Path("actor/{actorName}")
+ @Produces("application/json")
+ public Response getTasksForActor(
+ @PathParam("actorName")
+ String actorName
+ )
+ {
+ TaskReferenceWrapper wrapper =
+ new TaskReferenceWrapper(getTaskDAO().getTasksByActor(actorName));
+ return createJsonResponse(wrapper);
+ }
+
+ @GET
+ @Path("forms/{processId}")
+ @Produces("application/json")
+ public Response getTasksForms(
+ @PathParam("processId")
+ long processId
+ )
+ {
+ Map<String,String> formMapping =
+ getExtensionDAO().getAvailableTaskForms(processId);
+
+ List<MapEntry> entries = new ArrayList<MapEntry>();
+ for(String s : formMapping.keySet())
+ {
+ entries.add( new MapEntry(s, formMapping.get(s)) );
+ }
+
+ return createJsonResponse( entries );
+ }
+
+ @POST
+ @Path("{taskId}/assignment/{actorId}")
+ @Produces("application/json")
+ public Response assignTask(
+ @PathParam("taskId")
+ long taskId,
+ @PathParam("actorId")
+ String actorId
+ )
+ {
+ log.debug("Reassign task " + taskId + " to '" + actorId +"'");
+ getTaskDAO().reassignTask(taskId, actorId);
+ return Response.ok().build();
+ }
+
+ @POST
+ @Path("{taskId}/assignment")
+ @Produces("application/json")
+ public Response releaseTask(
+ @PathParam("taskId")
+ long taskId
+ )
+ {
+ log.debug("Release task " + taskId);
+ getTaskDAO().reassignTask(taskId, null);
+ return Response.ok().build();
+ }
+
+ @POST
+ @Path("{taskId}/close/transition/default")
+ @Produces("application/json")
+ public Response closeTask(
+ @PathParam("taskId")
+ long taskId
+ )
+ {
+ return closeTaskWithSignal(taskId, null);
+ }
+
+ @POST
+ @Path("{taskId}/close/transition")
+ @Produces("application/json")
+ public Response closeTaskWithSignal(
+ @PathParam("taskId")
+ long taskId,
+ @QueryParam("signal")
+ String signalName
+ )
+ {
+ log.debug("Close task " + taskId);
+ getTaskDAO().closeTask(taskId, signalName);
+ return Response.ok().build();
+ }
+
+
+ @GET
+ @Path("forms/{processId}/{taskId}")
+ @Produces("application/json")
+ public Response getTasksFormByTaskId(
+ @PathParam("processId")
+ long processId,
+ @PathParam("taskId")
+ long taskId
+
+ )
+ {
+ byte[] form = getExtensionDAO().getTaskFormByTaskName(processId, taskId);
+ JBPM3FormParser parser = new JBPM3FormParser();
+ final FormDef formDef = new FormDef("taskform-"+taskId);
+ try
+ {
+ parser.parse( new ByteArrayInputStream(form));
+
+ parser.visitResults(
+ new JBPM3FormParser.ParseResultVisitor()
+ {
+
+ public void onInputField(FieldDef field)
+ {
+ formDef.getFields().add(field);
+ }
+
+ public void onInputButton(JBPM3FormParser.InputButton btn)
+ {
+ // TODO: parse buttons
+ }
+ }
+ );
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to parse form data", e);
+ }
+
+ return createJsonResponse(formDef);
+ }
+
+ private Response createJsonResponse(Object wrapper)
+ {
+ Gson gson = GsonFactory.createInstance();
+ String json = gson.toJson(wrapper);
+ return Response.ok(json).type("application/json").build();
+ }
+}
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,83 +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.server;
-
-import org.jboss.bpm.console.client.model.RoleAssignment;
-import org.jboss.bpm.console.client.model.RoleAssignmentWrapper;
-import org.jboss.bpm.console.server.gson.GsonFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import com.google.gson.Gson;
-
-/**
- * REST server module for accessing user related data.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at Path("user")
-public class UserManagement
-{
-
- private static final Log log = LogFactory.getLog(UserManagement.class);
-
- @GET
- @Path("roles")
- @Produces("application/json")
- public Response getAssignedRoles(
- @Context
- HttpServletRequest request,
- @QueryParam("roleCheck")
- String roleCheck
- )
- {
- if(null==roleCheck)
- throw new WebApplicationException( new IllegalArgumentException("Missing parameter 'roleCheck'") );
-
- log.debug("Role check user: " + request.getRemoteUser() + ", actualRoles requested: " + roleCheck);
-
- List<RoleAssignment> actualRoles = new ArrayList<RoleAssignment>();
-
- StringTokenizer tok = new StringTokenizer(roleCheck, ",");
- while(tok.hasMoreTokens())
- {
- String possibleRole = tok.nextToken();
- actualRoles.add( new RoleAssignment(possibleRole, request.isUserInRole(possibleRole)));
- }
- return createJsonResponse( new RoleAssignmentWrapper(actualRoles));
- }
-
- private Response createJsonResponse(Object wrapper)
- {
- Gson gson = GsonFactory.createInstance();
- String json = gson.toJson(wrapper);
- return Response.ok(json).type("application/json").build();
- }
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java (from rev 2799, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,124 @@
+/*
+ * 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.server;
+
+import org.jboss.bpm.console.client.model.RoleAssignment;
+import org.jboss.bpm.console.client.model.RoleAssignmentWrapper;
+import org.jboss.bpm.console.server.gson.GsonFactory;
+import org.jboss.bpm.console.server.dao.UserManagement;
+import org.jboss.bpm.console.server.dao.ManagementFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import com.google.gson.Gson;
+
+/**
+ * REST server module for accessing user related data.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("identity")
+public class UserMgmtFacade
+{
+
+ private static final Log log = LogFactory.getLog(UserMgmtFacade.class);
+
+ private UserManagement userManagement;
+
+ private UserManagement getUserManagement()
+ {
+ if(null==userManagement)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.userManagement = factory.createUsermanagement();
+ }
+
+ return this.userManagement;
+ }
+
+ @GET
+ @Path("/user/roles")
+ @Produces("application/json")
+ public Response getRolesForJAASPrincipal(
+ @Context
+ HttpServletRequest request,
+ @QueryParam("roleCheck")
+ String roleCheck
+ )
+ {
+ // TODO: Why not use the identity DB right away?
+ // These roles are security roles
+ if(null==roleCheck)
+ throw new WebApplicationException( new IllegalArgumentException("Missing parameter 'roleCheck'") );
+
+ log.debug("Role check user: " + request.getRemoteUser() + ", actualRoles requested: " + roleCheck);
+
+ List<RoleAssignment> actualRoles = new ArrayList<RoleAssignment>();
+
+ StringTokenizer tok = new StringTokenizer(roleCheck, ",");
+ while(tok.hasMoreTokens())
+ {
+ String possibleRole = tok.nextToken();
+ actualRoles.add( new RoleAssignment(possibleRole, request.isUserInRole(possibleRole)));
+ }
+ return createJsonResponse( new RoleAssignmentWrapper(actualRoles));
+ }
+
+ @GET
+ @Path("/user/{actorId}/groups/")
+ @Produces("application/json")
+ public Response getGroupsForActor(
+ @PathParam("actorId")
+ String actorId
+ )
+ {
+ List<String> groups = getUserManagement().getGroupsForActor(actorId);
+ return createJsonResponse(groups);
+ }
+
+ @GET
+ @Path("/group/{groupName}/members")
+ @Produces("application/json")
+ public Response getActorsForGroup(
+ @PathParam("groupName")
+ String groupName
+ )
+ {
+ List<String> groups = getUserManagement().getActorsForGroup(groupName);
+ return createJsonResponse(groups);
+ }
+
+ private Response createJsonResponse(Object wrapper)
+ {
+ Gson gson = GsonFactory.createInstance();
+ String json = gson.toJson(wrapper);
+ return Response.ok(json).type("application/json").build();
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,51 +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.server.dao;
-
-import org.jboss.bpm.console.server.util.ServiceLoader;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public abstract class DAOFactory
-{
- public abstract ProcessDAO createProcessDAO();
-
- public abstract ExtensionDAO createDiagramDAO();
-
- public abstract TaskDAO createTaskDAO();
-
- /**
- * Load a DAOFactory through {@link org.jboss.bpm.console.server.util.ServiceLoader}
- * @return a DAOFactory implementation
- */
- public static DAOFactory newInstance()
- {
- DAOFactory factory = (DAOFactory)
- ServiceLoader.loadFromServices(DAOFactory.class.getName(), "org.jboss.bpm.console.server.dao.internal.JBPM3DAOFactory");
- if(null==factory)
- throw new RuntimeException("Failed to load DAOFactory.");
-
- return factory;
- }
-
-}
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,96 +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.server.dao;
-
-import org.jboss.bpm.console.server.util.ServiceLocator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.transaction.SystemException;
-import javax.transaction.UserTransaction;
-import java.lang.reflect.Method;
-
-/**
- * Decorates DAO invocations with common system aspects, i.e. transaction demarcation.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class DAOProxy implements java.lang.reflect.InvocationHandler
-{
- private static final Log log = LogFactory.getLog(DAOProxy.class);
-
- private Object obj;
-
- public static Object newInstance(Object obj) {
- return java.lang.reflect.Proxy.newProxyInstance(
- obj.getClass().getClassLoader(),
- obj.getClass().getInterfaces(),
- new DAOProxy(obj));
- }
-
- private DAOProxy(Object obj) {
- this.obj = obj;
- }
-
- public Object invoke(Object proxy, Method m, Object[] args)
- throws Throwable
- {
- Object result;
-
- UserTransaction tx = ServiceLocator.getUserTransaction();
-
- try
- {
- // before method invocation
- tx.begin();
-
- // field target invocation
- result = m.invoke(obj, args);
-
- tx.commit();
-
- }
- catch (Throwable e)
- {
- if(tx!=null)
- {
- try
- {
- tx.rollback();
- }
- catch (SystemException e1) {
- log.error("Failed to rollback on " + obj + " -> " + m.getName());
- }
- }
-
- throw new RuntimeException("Unexpected invocation exception: " + e.getMessage(), e);
-
- }
- finally
- {
- // after method invocation
-
- }
-
- return result;
- }
-}
\ No newline at end of file
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ExtensionDAO.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ExtensionDAO.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ExtensionDAO.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,42 +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.server.dao;
-
-import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
-import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
-import org.jboss.bpm.console.server.dao.ProcessDAO;
-
-/**
- * Proprietary to jBPM3, no sure if it will stay.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public interface ExtensionDAO
-{
- byte[] getProcessImage(long processId);
-
- DiagramInfo getDiagramInfo(long processId);
-
- ActiveNodeInfo getActivNodeInfo(long instanceId);
-
- void signalToken(long tokenId, String signal);
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/InvocationProxy.java (from rev 2910, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/InvocationProxy.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/InvocationProxy.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,96 @@
+/*
+ * 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.server.dao;
+
+import org.jboss.bpm.console.server.util.ServiceLocator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+import java.lang.reflect.Method;
+
+/**
+ * Decorates management invocations with common system aspects, i.e. transaction demarcation.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class InvocationProxy implements java.lang.reflect.InvocationHandler
+{
+ private static final Log log = LogFactory.getLog(InvocationProxy.class);
+
+ private Object obj;
+
+ public static Object newInstance(Object obj) {
+ return java.lang.reflect.Proxy.newProxyInstance(
+ obj.getClass().getClassLoader(),
+ obj.getClass().getInterfaces(),
+ new InvocationProxy(obj));
+ }
+
+ private InvocationProxy(Object obj) {
+ this.obj = obj;
+ }
+
+ public Object invoke(Object proxy, Method m, Object[] args)
+ throws Throwable
+ {
+ Object result;
+
+ UserTransaction tx = ServiceLocator.getUserTransaction();
+
+ try
+ {
+ // before method invocation
+ tx.begin();
+
+ // field target invocation
+ result = m.invoke(obj, args);
+
+ tx.commit();
+
+ }
+ catch (Throwable e)
+ {
+ if(tx!=null)
+ {
+ try
+ {
+ tx.rollback();
+ }
+ catch (SystemException e1) {
+ log.error("Failed to rollback on " + obj + " -> " + m.getName());
+ }
+ }
+
+ throw new RuntimeException("Unexpected invocation exception: " + e.getMessage(), e);
+
+ }
+ finally
+ {
+ // after method invocation
+
+ }
+
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/InvocationProxy.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/JBPM3Extension.java (from rev 2904, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ExtensionDAO.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/JBPM3Extension.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/JBPM3Extension.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,48 @@
+/*
+ * 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.server.dao;
+
+import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+
+import java.util.Map;
+
+/**
+ * Proprietary to jBPM3, no sure if it will stay.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface JBPM3Extension
+{
+ byte[] getProcessImage(long processId);
+
+ DiagramInfo getDiagramInfo(long processId);
+
+ ActiveNodeInfo getActivNodeInfo(long instanceId);
+
+ void signalToken(long tokenId, String signal);
+
+ Map<String, String> getAvailableTaskForms(long processId);
+
+ byte[] getTaskFormByTaskName(long processId, long taskId);
+
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/JBPM3Extension.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ManagementFactory.java (from rev 2904, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ManagementFactory.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ManagementFactory.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,56 @@
+/*
+ * 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.server.dao;
+
+import org.jboss.bpm.console.server.util.ServiceLoader;
+
+/**
+ * Construct management implementations.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public abstract class ManagementFactory
+{
+ public abstract ProcessManagement createProcessManagement();
+
+ // TODO: remove from base class. It's proprietary to jbpm3
+ public abstract JBPM3Extension createExtensionManagement();
+
+ public abstract TaskManagement createTaskManagement();
+
+ public abstract UserManagement createUsermanagement();
+
+ /**
+ * Load a ManagementFactory through {@link org.jboss.bpm.console.server.util.ServiceLoader}
+ * @return a ManagementFactory implementation
+ */
+ public static ManagementFactory newInstance()
+ {
+ ManagementFactory factory = (ManagementFactory)
+ ServiceLoader.loadFromServices(ManagementFactory.class.getName(), "org.jboss.bpm.console.server.dao.internal.JBPM3ManagementFactory");
+ if(null==factory)
+ throw new RuntimeException("Failed to load ManagementFactory.");
+
+ return factory;
+ }
+
+}
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,54 +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.server.dao;
-
-import org.jboss.bpm.console.client.model.ProcessDefinition;
-import org.jboss.bpm.console.client.model.ProcessInstance;
-import org.jboss.bpm.console.client.model.TaskReference;
-
-import java.util.List;
-
-/**
- * Access process related data.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public interface ProcessDAO
-{
- List<ProcessDefinition> getAllDefinitions();
-
- ProcessDefinition getDefinitionById(long processId);
-
- List<ProcessDefinition> removeDefinition(long processId);
-
- List<ProcessInstance> getInstancesByProcessId(long processId);
-
- ProcessInstance getInstanceById(long instanceId);
-
- void changeState(long instanceId, String nextState);
-
- ProcessInstance newInstance(long processId);
-
- ProcessDefinition deployNewDefinition(byte[] data);
-
- List<TaskReference> getAllTasks();
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessManagement.java (from rev 2755, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,53 @@
+/*
+ * 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.server.dao;
+
+import org.jboss.bpm.console.client.model.ProcessDefinition;
+import org.jboss.bpm.console.client.model.ProcessInstance;
+import org.jboss.bpm.console.client.model.TaskReference;
+
+import java.util.List;
+
+/**
+ * Access process related data.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface ProcessManagement
+{
+ List<ProcessDefinition> getAllDefinitions();
+
+ ProcessDefinition getDefinitionById(long processId);
+
+ List<ProcessDefinition> removeDefinition(long processId);
+
+ List<ProcessInstance> getInstancesByProcessId(long processId);
+
+ ProcessInstance getInstanceById(long instanceId);
+
+ void changeState(long instanceId, String nextState);
+
+ ProcessInstance newInstance(long processId);
+
+ ProcessDefinition deployNewDefinition(byte[] data);
+
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessManagement.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskDAO.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskDAO.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskDAO.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,41 +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.server.dao;
-
-import org.jboss.bpm.console.client.model.TaskReference;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public interface TaskDAO
-{
- List<TaskReference> getTasksByActor(String actorName);
- Map<String, String> getAvailableTaskForms(long processId);
- byte[] getTaskFormByTaskName(long processId, long taskId);
-
- TaskReference getTaskById(long taskId);
- void reassignTask(long taskId, String actorId);
- void closeTask(long taskId, String signalName);
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskManagement.java (from rev 2962, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskDAO.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/TaskManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,40 @@
+/*
+ * 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.server.dao;
+
+import org.jboss.bpm.console.client.model.TaskReference;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface TaskManagement
+{
+ List<TaskReference> getTasksByActor(String actorName);
+ TaskReference getTaskById(long taskId);
+ void reassignTask(long taskId, String actorId);
+
+ // TODO: If signaling resides with an extension then closeTask() should as well
+ void closeTask(long taskId, String signalName);
+}
Added: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/UserManagement.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/UserManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/UserManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,33 @@
+/*
+ * 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.server.dao;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface UserManagement
+{
+ List<String> getGroupsForActor(String actorId);
+ List<String> getActorsForGroup(String groupName);
+}
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -26,14 +26,13 @@
import org.jbpm.ejb.LocalCommandServiceHome;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.taskmgmt.exe.TaskInstance;
-import org.jbpm.identity.Group;
import org.jboss.bpm.console.server.util.ServiceLocator;
-import org.jboss.bpm.console.server.dao.internal.cmd.GetGroupMemershipCommand;
+import org.jboss.bpm.console.server.dao.internal.cmd.GetGroupMembershipCommand;
+import org.jboss.bpm.console.server.dao.internal.cmd.GetUsersForGroupCommand;
import javax.ejb.CreateException;
import java.util.List;
import java.util.ArrayList;
-import java.util.Set;
/**
* Adopts a business interface to the command facade.<br>
@@ -152,9 +151,7 @@
public List<TaskInstance> getActualTasksForActor(String actorName)
{
- List<String> groupNames = (List<String>)facade.execute(
- new GetGroupMemershipCommand(actorName)
- );
+ List<String> groupNames = getGroupsForActor(actorName);
String[] actors = new String[groupNames.size()+1];
int i=0;
@@ -172,6 +169,22 @@
return tasks;
}
+ public List<String> getGroupsForActor(String actorName)
+ {
+ List<String> groupNames = (List<String>)facade.execute(
+ new GetGroupMembershipCommand(actorName)
+ );
+ return groupNames;
+ }
+
+ public List<String> getActorsForGroup(String groupName)
+ {
+ List<String> actorIds = (List<String>)facade.execute(
+ new GetUsersForGroupCommand(groupName)
+ );
+ return actorIds;
+ }
+
public TaskInstance getTaskById(long taskId)
{
// include variables, but no logs
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,47 +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.server.dao.internal;
-
-import org.jboss.bpm.console.server.dao.*;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class JBPM3DAOFactory extends DAOFactory
-{
-
- public ProcessDAO createProcessDAO()
- {
- return (ProcessDAO) DAOProxy.newInstance(new JBPM3ProcessDAO());
- }
-
- public ExtensionDAO createDiagramDAO()
- {
- return (ExtensionDAO) DAOProxy.newInstance( new JBPM3ExtensionDAO() );
- }
-
-
- public TaskDAO createTaskDAO()
- {
- return (TaskDAO) DAOProxy.newInstance( new JBPM3TaskDAO() );
- }
-}
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ExtensionDAO.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ExtensionDAO.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ExtensionDAO.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,90 +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.server.dao.internal;
-
-import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
-import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
-import org.jboss.bpm.console.client.model.jbpm3.DiagramNodeInfo;
-import org.jboss.bpm.console.server.dao.ExtensionDAO;
-
-import java.io.InputStream;
-import java.util.List;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class JBPM3ExtensionDAO implements ExtensionDAO
-{
- private JBPM3CommandDelegate delegate;
-
- private static final String PROCESSIMAGE_FILENAME = "processimage.jpg";
- private static final String GPD_XML_FILENAME = "gpd.xml";
-
- public JBPM3ExtensionDAO()
- {
- this.delegate = new JBPM3CommandDelegate();
- }
-
- public byte[] getProcessImage(long processId)
- {
- org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
- return p0.getFileDefinition().getBytes(PROCESSIMAGE_FILENAME);
- }
-
- public DiagramInfo getDiagramInfo(long processId)
- {
- org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
- InputStream in = p0.getFileDefinition().getInputStream(GPD_XML_FILENAME);
- return DiagramInfoParser.parse(in);
- }
-
- public ActiveNodeInfo getActivNodeInfo(long instanceId)
- {
- org.jbpm.graph.exe.ProcessInstance instance = delegate.getActualInstance(instanceId);
- String currentNodeName = instance.getRootToken().getNode().getName();
-
- DiagramInfo diagram = getDiagramInfo(instance.getProcessDefinition().getId());
- List<DiagramNodeInfo> nodes = diagram.getNodeList();
-
- DiagramNodeInfo activeNode = null;
- int i = 0;
- for(DiagramNodeInfo n : nodes)
- {
- if(currentNodeName.equals(n.getName()))
- {
- activeNode = n;
- break;
- }
- }
-
- if(null==activeNode)
- throw new RuntimeException("Failed to retrieve activeNodeInfo for instance " + instanceId);
-
- return new ActiveNodeInfo(diagram.getWidth(), diagram.getHeight(), activeNode);
- }
-
-
- public void signalToken(long tokenId, String signal)
- {
- delegate.signalToken(tokenId, signal);
- }
-}
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3FormParser.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -36,7 +36,7 @@
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class JBPM3FormParser
+class JBPM3FormParser
{
private static final Log log = LogFactory.getLog(JBPM3FormParser.class);
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementExtension.java (from rev 2904, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ExtensionDAO.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementExtension.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementExtension.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,156 @@
+/*
+ * 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.server.dao.internal;
+
+import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramNodeInfo;
+import org.jboss.bpm.console.server.dao.JBPM3Extension;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.file.def.FileDefinition;
+import org.jbpm.util.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPM3ManagementExtension implements JBPM3Extension
+{
+ private JBPM3CommandDelegate delegate;
+
+ private static final String PROCESSIMAGE_FILENAME = "processimage.jpg";
+ private static final String GPD_XML_FILENAME = "gpd.xml";
+
+ public JBPM3ManagementExtension()
+ {
+ this.delegate = new JBPM3CommandDelegate();
+ }
+
+ public byte[] getProcessImage(long processId)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ return p0.getFileDefinition().getBytes(PROCESSIMAGE_FILENAME);
+ }
+
+ public DiagramInfo getDiagramInfo(long processId)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ InputStream in = p0.getFileDefinition().getInputStream(GPD_XML_FILENAME);
+ return DiagramInfoParser.parse(in);
+ }
+
+ public ActiveNodeInfo getActivNodeInfo(long instanceId)
+ {
+ org.jbpm.graph.exe.ProcessInstance instance = delegate.getActualInstance(instanceId);
+ String currentNodeName = instance.getRootToken().getNode().getName();
+
+ DiagramInfo diagram = getDiagramInfo(instance.getProcessDefinition().getId());
+ List<DiagramNodeInfo> nodes = diagram.getNodeList();
+
+ DiagramNodeInfo activeNode = null;
+ int i = 0;
+ for(DiagramNodeInfo n : nodes)
+ {
+ if(currentNodeName.equals(n.getName()))
+ {
+ activeNode = n;
+ break;
+ }
+ }
+
+ if(null==activeNode)
+ throw new RuntimeException("Failed to retrieve activeNodeInfo for instance " + instanceId);
+
+ return new ActiveNodeInfo(diagram.getWidth(), diagram.getHeight(), activeNode);
+ }
+
+
+ public void signalToken(long tokenId, String signal)
+ {
+ delegate.signalToken(tokenId, signal);
+ }
+
+ public Map<String, String> getAvailableTaskForms(long processId)
+ {
+ org.jbpm.graph.def.ProcessDefinition processDefinition =
+ delegate.getActualDefinition(processId);
+
+ return getTask2FileMapping(processDefinition);
+ }
+
+ private Map<String, String> getTask2FileMapping(ProcessDefinition processDefinition)
+ {
+ Map<String, String> result = new HashMap<String, String>();
+
+ final FileDefinition fileDefinition = processDefinition.getFileDefinition();
+ if (! fileDefinition.hasFile("forms.xml"))
+ {
+ // exit with empty list
+ // TODO: maybe an exception is better?
+ return result;
+ }
+
+ final InputStream inputStream = fileDefinition.getInputStream("forms.xml");
+ if (inputStream == null)
+ {
+ throw new RuntimeException("Failed to open stream on forms.xml");
+ }
+
+ final Document document = XmlUtil.parseXmlInputStream(inputStream);
+ final Element documentElement = document.getDocumentElement();
+ final NodeList nodeList = documentElement.getElementsByTagName("form");
+ final int length = nodeList.getLength();
+ for (int i = 0; i < length; i ++)
+ {
+ final Element element = (Element) nodeList.item(i);
+ final String itemTaskName = element.getAttribute("task");
+ final String itemFormName = element.getAttribute("form");
+ if (itemTaskName == null || itemFormName == null) {
+ continue;
+ }
+ result.put(itemTaskName, itemFormName);
+ }
+ return result;
+ }
+
+ public byte[] getTaskFormByTaskName(long processId, long taskId)
+ {
+ org.jbpm.graph.def.ProcessDefinition processDefinition =
+ delegate.getActualDefinition(processId);
+ org.jbpm.taskmgmt.exe.TaskInstance t0 = delegate.getTaskById(taskId);
+
+ Map<String,String> fileMapping = getTask2FileMapping(processDefinition);
+ String fileName = fileMapping.get(t0.getName());
+ if(fileName !=null)
+ return processDefinition.getFileDefinition().getBytes(fileName);
+ else
+ throw new RuntimeException("No form definition for taskId '"+taskId+"'");
+
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementExtension.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementFactory.java (from rev 2904, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementFactory.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementFactory.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,54 @@
+/*
+ * 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.server.dao.internal;
+
+import org.jboss.bpm.console.server.dao.*;
+
+/**
+ * Wraps management instances in {@link org.jboss.bpm.console.server.dao.InvocationProxy}
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPM3ManagementFactory extends ManagementFactory
+{
+
+ public ProcessManagement createProcessManagement()
+ {
+ return (ProcessManagement) InvocationProxy.newInstance(new JBPM3ProcessManagement());
+ }
+
+ public JBPM3Extension createExtensionManagement()
+ {
+ return (JBPM3Extension) InvocationProxy.newInstance( new JBPM3ManagementExtension() );
+ }
+
+
+ public TaskManagement createTaskManagement()
+ {
+ return (TaskManagement) InvocationProxy.newInstance( new JBPM3TaskManagement() );
+ }
+
+
+ public UserManagement createUsermanagement()
+ {
+ return (UserManagement) InvocationProxy.newInstance( new JBPM3UserManagement() );
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ManagementFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,114 +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.server.dao.internal;
-
-import org.jboss.bpm.console.client.model.ProcessDefinition;
-import org.jboss.bpm.console.client.model.ProcessInstance;
-import org.jboss.bpm.console.client.model.TaskReference;
-import org.jboss.bpm.console.server.dao.ProcessDAO;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class JBPM3ProcessDAO implements ProcessDAO
-{
- private JBPM3CommandDelegate delegate;
-
- public JBPM3ProcessDAO()
- {
- this.delegate = new JBPM3CommandDelegate();
- }
-
- public List<ProcessDefinition> getAllDefinitions()
- {
- List<org.jbpm.graph.def.ProcessDefinition> defs = delegate.getActualDefinitions();
-
- List<ProcessDefinition> results = new ArrayList<ProcessDefinition>(defs.size());
- for(org.jbpm.graph.def.ProcessDefinition p0 : defs)
- {
- results.add( Transform.processDefinition(p0) );
- }
- return results;
- }
-
- public ProcessDefinition getDefinitionById(long processId)
- {
- org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
- return Transform.processDefinition(p0);
- }
-
- public List<ProcessDefinition> removeDefinition(long processId)
- {
- delegate.removeActualDefinition(processId);
- return getAllDefinitions();
- }
-
-
- public ProcessInstance newInstance(long processId)
- {
- org.jbpm.graph.exe.ProcessInstance instance = delegate.startNewInstance(processId);
- return Transform.processInstance(instance);
- }
-
- public List<ProcessInstance> getInstancesByProcessId(long processId)
- {
- List<org.jbpm.graph.exe.ProcessInstance> instances = delegate.getActualInstances(processId);
- List<ProcessInstance> results = new ArrayList<ProcessInstance>(instances.size());
- for(org.jbpm.graph.exe.ProcessInstance i0 : instances)
- {
- results.add( Transform.processInstance(i0) );
- }
- return results;
- }
-
- public ProcessInstance getInstanceById(long instanceId)
- {
- org.jbpm.graph.exe.ProcessInstance instance = delegate.getActualInstance(instanceId);
- return Transform.processInstance(instance);
- }
-
-
- public void changeState(long instanceId, String nextState)
- {
- org.jbpm.graph.exe.ProcessInstance p0 = delegate.getActualInstance(instanceId);
- Transform.doTransition(p0, nextState); // modifies the actual PI
-
- // TX commit will persist changes to the actual PI
-
-
- }
-
- public ProcessDefinition deployNewDefinition(byte[] data)
- {
- org.jbpm.graph.def.ProcessDefinition p0 = delegate.deploy(data);
- return Transform.processDefinition(p0);
- }
-
-
- public List<TaskReference> getAllTasks()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessManagement.java (from rev 2755, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,107 @@
+/*
+ * 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.server.dao.internal;
+
+import org.jboss.bpm.console.client.model.ProcessDefinition;
+import org.jboss.bpm.console.client.model.ProcessInstance;
+import org.jboss.bpm.console.server.dao.ProcessManagement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPM3ProcessManagement implements ProcessManagement
+{
+ private JBPM3CommandDelegate delegate;
+
+ public JBPM3ProcessManagement()
+ {
+ this.delegate = new JBPM3CommandDelegate();
+ }
+
+ public List<ProcessDefinition> getAllDefinitions()
+ {
+ List<org.jbpm.graph.def.ProcessDefinition> defs = delegate.getActualDefinitions();
+
+ List<ProcessDefinition> results = new ArrayList<ProcessDefinition>(defs.size());
+ for(org.jbpm.graph.def.ProcessDefinition p0 : defs)
+ {
+ results.add( Transform.processDefinition(p0) );
+ }
+ return results;
+ }
+
+ public ProcessDefinition getDefinitionById(long processId)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ return Transform.processDefinition(p0);
+ }
+
+ public List<ProcessDefinition> removeDefinition(long processId)
+ {
+ delegate.removeActualDefinition(processId);
+ return getAllDefinitions();
+ }
+
+
+ public ProcessInstance newInstance(long processId)
+ {
+ org.jbpm.graph.exe.ProcessInstance instance = delegate.startNewInstance(processId);
+ return Transform.processInstance(instance);
+ }
+
+ public List<ProcessInstance> getInstancesByProcessId(long processId)
+ {
+ List<org.jbpm.graph.exe.ProcessInstance> instances = delegate.getActualInstances(processId);
+ List<ProcessInstance> results = new ArrayList<ProcessInstance>(instances.size());
+ for(org.jbpm.graph.exe.ProcessInstance i0 : instances)
+ {
+ results.add( Transform.processInstance(i0) );
+ }
+ return results;
+ }
+
+ public ProcessInstance getInstanceById(long instanceId)
+ {
+ org.jbpm.graph.exe.ProcessInstance instance = delegate.getActualInstance(instanceId);
+ return Transform.processInstance(instance);
+ }
+
+
+ public void changeState(long instanceId, String nextState)
+ {
+ org.jbpm.graph.exe.ProcessInstance p0 = delegate.getActualInstance(instanceId);
+ Transform.doTransition(p0, nextState); // modifies the actual PI
+
+ // TX commit will persist changes to the actual PI
+
+
+ }
+
+ public ProcessDefinition deployNewDefinition(byte[] data)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.deploy(data);
+ return Transform.processDefinition(p0);
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessManagement.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskDAO.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskDAO.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskDAO.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,149 +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.server.dao.internal;
-
-import org.jboss.bpm.console.client.model.TaskReference;
-import org.jboss.bpm.console.server.dao.TaskDAO;
-import org.jbpm.file.def.FileDefinition;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.util.XmlUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class JBPM3TaskDAO implements TaskDAO
-{
-
- private JBPM3CommandDelegate delegate;
-
- public JBPM3TaskDAO()
- {
- this.delegate = new JBPM3CommandDelegate();
- }
-
- public List<TaskReference> getTasksByActor(String actorName)
- {
-
- List<org.jbpm.taskmgmt.exe.TaskInstance> actualTasks =
- delegate.getActualTasksForActor(actorName);
-
- List<TaskReference> taskRefs = new ArrayList<TaskReference>();
- for(org.jbpm.taskmgmt.exe.TaskInstance t0 : actualTasks)
- {
- taskRefs.add( Transform.taskInstance(t0));
- }
-
- List<TaskReference> copy = new ArrayList<TaskReference>();
- for(TaskReference ref : taskRefs)
- {
- copy.add(ref);
- }
- return copy;
- }
-
- public Map<String, String> getAvailableTaskForms(long processId)
- {
- org.jbpm.graph.def.ProcessDefinition processDefinition =
- delegate.getActualDefinition(processId);
-
- return getTask2FileMapping(processDefinition);
- }
-
- private Map<String, String> getTask2FileMapping(ProcessDefinition processDefinition)
- {
- Map<String, String> result = new HashMap<String, String>();
-
- final FileDefinition fileDefinition = processDefinition.getFileDefinition();
- if (! fileDefinition.hasFile("forms.xml"))
- {
- // exit with empty list
- // TODO: maybe an exception is better?
- return result;
- }
-
- final InputStream inputStream = fileDefinition.getInputStream("forms.xml");
- if (inputStream == null)
- {
- throw new RuntimeException("Failed to open stream on forms.xml");
- }
-
- final Document document = XmlUtil.parseXmlInputStream(inputStream);
- final Element documentElement = document.getDocumentElement();
- final NodeList nodeList = documentElement.getElementsByTagName("form");
- final int length = nodeList.getLength();
- for (int i = 0; i < length; i ++)
- {
- final Element element = (Element) nodeList.item(i);
- final String itemTaskName = element.getAttribute("task");
- final String itemFormName = element.getAttribute("form");
- if (itemTaskName == null || itemFormName == null) {
- continue;
- }
- result.put(itemTaskName, itemFormName);
- }
- return result;
- }
-
- public byte[] getTaskFormByTaskName(long processId, long taskId)
- {
- org.jbpm.graph.def.ProcessDefinition processDefinition =
- delegate.getActualDefinition(processId);
- org.jbpm.taskmgmt.exe.TaskInstance t0 = delegate.getTaskById(taskId);
-
- Map<String,String> fileMapping = getTask2FileMapping(processDefinition);
- String fileName = fileMapping.get(t0.getName());
- if(fileName !=null)
- return processDefinition.getFileDefinition().getBytes(fileName);
- else
- throw new RuntimeException("No form definition for taskId '"+taskId+"'");
-
- }
-
- public TaskReference getTaskById(long taskId)
- {
- org.jbpm.taskmgmt.exe.TaskInstance t0 = delegate.getTaskById(taskId);
- TaskReference taskRef = Transform.taskInstance(t0);
- return taskRef;
- }
-
-
- public void reassignTask(long taskId, String actorId)
- {
- // TODO: validation of actorId?
- delegate.assignTask(taskId, actorId);
- }
-
-
- public void closeTask(long taskId, String signalName)
- {
- delegate.endTask(taskId, signalName);
- }
-}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskManagement.java (from rev 2962, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskDAO.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3TaskManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,82 @@
+/*
+ * 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.server.dao.internal;
+
+import org.jboss.bpm.console.client.model.TaskReference;
+import org.jboss.bpm.console.server.dao.TaskManagement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPM3TaskManagement implements TaskManagement
+{
+
+ private JBPM3CommandDelegate delegate;
+
+ public JBPM3TaskManagement()
+ {
+ this.delegate = new JBPM3CommandDelegate();
+ }
+
+ public List<TaskReference> getTasksByActor(String actorName)
+ {
+
+ List<org.jbpm.taskmgmt.exe.TaskInstance> actualTasks =
+ delegate.getActualTasksForActor(actorName);
+
+ List<TaskReference> taskRefs = new ArrayList<TaskReference>();
+ for(org.jbpm.taskmgmt.exe.TaskInstance t0 : actualTasks)
+ {
+ taskRefs.add( Transform.taskInstance(t0));
+ }
+
+ List<TaskReference> copy = new ArrayList<TaskReference>();
+ for(TaskReference ref : taskRefs)
+ {
+ copy.add(ref);
+ }
+ return copy;
+ }
+
+ public TaskReference getTaskById(long taskId)
+ {
+ org.jbpm.taskmgmt.exe.TaskInstance t0 = delegate.getTaskById(taskId);
+ TaskReference taskRef = Transform.taskInstance(t0);
+ return taskRef;
+ }
+
+
+ public void reassignTask(long taskId, String actorId)
+ {
+ // TODO: validation of actorId?
+ delegate.assignTask(taskId, actorId);
+ }
+
+
+ public void closeTask(long taskId, String signalName)
+ {
+ delegate.endTask(taskId, signalName);
+ }
+}
Added: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3UserManagement.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3UserManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3UserManagement.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,50 @@
+/*
+ * 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.server.dao.internal;
+
+import org.jboss.bpm.console.server.dao.UserManagement;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPM3UserManagement implements UserManagement
+{
+
+ private JBPM3CommandDelegate delegate;
+
+ public JBPM3UserManagement()
+ {
+ this.delegate = new JBPM3CommandDelegate();
+ }
+
+ public List<String> getGroupsForActor(String actorId)
+ {
+ return delegate.getGroupsForActor(actorId);
+ }
+
+ public List<String> getActorsForGroup(String groupName)
+ {
+ return delegate.getActorsForGroup(groupName);
+ }
+}
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -37,7 +37,7 @@
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class Transform
+class Transform
{
public static ProcessDefinition processDefinition(org.jbpm.graph.def.ProcessDefinition p0)
{
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMembershipCommand.java (from rev 2865, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMemershipCommand.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMembershipCommand.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMembershipCommand.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,72 @@
+/*
+ * 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.server.dao.internal.cmd;
+
+import org.jbpm.command.Command;
+import org.jbpm.command.AbstractGetObjectBaseCommand;
+import org.jbpm.JbpmContext;
+import org.jbpm.identity.hibernate.IdentitySession;
+import org.jbpm.identity.User;
+import org.jbpm.identity.Group;
+
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * TODO: Group resolution should be pluggable
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class GetGroupMembershipCommand extends AbstractGetObjectBaseCommand implements Command
+{
+ private static final long serialVersionUID = -1627380259541998349L;
+
+ private String actorName;
+
+ public GetGroupMembershipCommand(String actorName)
+ {
+ super();
+ this.actorName = actorName;
+ }
+
+ public Object execute(JbpmContext jbpmContext) throws Exception
+ {
+ List<String> groupNames = new ArrayList<String>();
+
+ setJbpmContext(jbpmContext);
+
+ IdentitySession session = new IdentitySession(
+ jbpmContext.getSession()
+ );
+
+ User user = session.getUserByName(actorName);
+ Set<Group> groups = (Set<Group>)user.getGroupsForGroupType("organisation");
+
+ for(Group g : groups)
+ {
+ groupNames.add(g.getName());
+ }
+
+ return groupNames;
+ }
+}
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMemershipCommand.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMemershipCommand.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetGroupMemershipCommand.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -1,70 +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.server.dao.internal.cmd;
-
-import org.jbpm.command.Command;
-import org.jbpm.command.AbstractGetObjectBaseCommand;
-import org.jbpm.JbpmContext;
-import org.jbpm.identity.hibernate.IdentitySession;
-import org.jbpm.identity.User;
-import org.jbpm.identity.Group;
-
-import java.util.Set;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class GetGroupMemershipCommand extends AbstractGetObjectBaseCommand implements Command
-{
- private static final long serialVersionUID = -1627380259541998349L;
-
- private String actorName;
-
- public GetGroupMemershipCommand(String actorName)
- {
- super();
- this.actorName = actorName;
- }
-
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
- List<String> groupNames = new ArrayList<String>();
-
- setJbpmContext(jbpmContext);
-
- IdentitySession session = new IdentitySession(
- jbpmContext.getSession()
- );
-
- User user = session.getUserByName(actorName);
- Set<Group> groups = (Set<Group>)user.getGroupsForGroupType("organisation");
-
- for(Group g : groups)
- {
- groupNames.add(g.getName());
- }
-
- return groupNames;
- }
-}
Added: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetUsersForGroupCommand.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetUsersForGroupCommand.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/dao/internal/cmd/GetUsersForGroupCommand.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,71 @@
+/*
+ * 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.server.dao.internal.cmd;
+
+import org.jbpm.command.Command;
+import org.jbpm.command.AbstractGetObjectBaseCommand;
+import org.jbpm.JbpmContext;
+import org.jbpm.identity.hibernate.IdentitySession;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * TODO: Group resolution should be pluggable
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class GetUsersForGroupCommand extends AbstractGetObjectBaseCommand implements Command
+{
+ private static final long serialVersionUID = -1627380259541998349L;
+
+ private String groupName;
+
+ public GetUsersForGroupCommand(String groupName)
+ {
+ super();
+ this.groupName = groupName;
+ }
+
+ public Object execute(JbpmContext jbpmContext) throws Exception
+ {
+ List<String> userNames = new ArrayList<String>();
+
+ setJbpmContext(jbpmContext);
+
+ IdentitySession session = new IdentitySession(
+ jbpmContext.getSession()
+ );
+
+ Group group = session.getGroupByName(groupName);
+ Set<User> users = group.getUsers();
+ for(User u : users)
+ {
+ userNames.add(u.getName());
+ }
+
+ return userNames;
+ }
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/BufferedResponseWrapper.java (from rev 2755, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/BufferedResponseWrapper.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/BufferedResponseWrapper.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,76 @@
+/*
+ * 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.server.util;
+
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at SuppressWarnings("deprecation")
+public class BufferedResponseWrapper extends HttpServletResponseWrapper
+{
+ private ByteArrayOutputStream output;
+ private int contentLength;
+ private String contentType = "";
+
+ public BufferedResponseWrapper(HttpServletResponse httpServletResponse)
+ {
+ super(httpServletResponse);
+ output=new ByteArrayOutputStream();
+ }
+
+ public byte[] getData() {
+ return output.toByteArray();
+ }
+
+ public ServletOutputStream getOutputStream() {
+ return new FilterServletOutputStream(output);
+ }
+
+ public PrintWriter getWriter() {
+ return new PrintWriter(getOutputStream(),true);
+ }
+
+ public void setContentLength(int length) {
+ this.contentLength = length;
+ super.setContentLength(length);
+ }
+
+ public int getContentLength() {
+ return contentLength;
+ }
+
+ public void setContentType(String type) {
+ this.contentType = type;
+ super.setContentType(type);
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/BufferedResponseWrapper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/FilterServletOutputStream.java (from rev 2755, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/FilterServletOutputStream.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/FilterServletOutputStream.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/FilterServletOutputStream.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,54 @@
+/*
+ * 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.server.util;
+
+import javax.servlet.ServletOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class FilterServletOutputStream extends ServletOutputStream
+{
+
+ private DataOutputStream stream;
+
+ public FilterServletOutputStream(OutputStream output) {
+ stream = new DataOutputStream(output);
+ }
+
+ public void write(int b) throws IOException {
+ stream.write(b);
+ }
+
+ public void write(byte[] b) throws IOException {
+ stream.write(b);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException
+ {
+ stream.write(b,off,len);
+ }
+
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/FilterServletOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/GWTJsonFilter.java (from rev 2755, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/GWTJsonFilter.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/GWTJsonFilter.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -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.server.util;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class GWTJsonFilter implements Filter
+{
+
+ public FilterConfig filterConfig;
+ private static final String COLLECTION_PREFIX = "{\"wrapper\":";
+ private static final String COLLECTION_SUFFIX = "}";
+
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ this.filterConfig = filterConfig;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException
+ {
+
+ boolean isSOPCallback = false;
+
+ // identify GWT json requests
+ if(request.getParameter("callback")!=null)
+ isSOPCallback = true;
+
+ // sneak in repsonse wrapper
+ OutputStream out = response.getOutputStream();
+ BufferedResponseWrapper wrapper = new BufferedResponseWrapper((HttpServletResponse) response);
+
+ // proceed chain
+ chain.doFilter(request, wrapper);
+
+ // add callback std. json output
+ String contentType = response.getContentType() != null ? response.getContentType() : "application/octet-stream";
+ boolean isJSONEncoding = contentType.equals("application/json");
+ StringBuffer sb = null;
+ if(isJSONEncoding)
+ {
+ String payload = new String(wrapper.getData());
+ String gwtextFriendly = trimPayload(payload);
+
+ sb = new StringBuffer();
+
+ if(isSOPCallback)
+ {
+ sb.append(request.getParameter("callback"));
+ sb.append("(");
+ }
+
+ // Strip wrapper when JSONRequest
+ sb.append(gwtextFriendly);
+
+ if(isSOPCallback)
+ {
+ sb.append(");");
+ }
+
+ }
+
+ // flush
+ if(sb!=null)
+ out.write(sb.toString().getBytes());
+ else
+ out.write(wrapper.getData());
+
+ out.flush();
+ out.close();
+ }
+
+ private String trimPayload(String payload)
+ {
+ String s = payload;
+ if(s.startsWith(COLLECTION_PREFIX))
+ {
+ s = payload.substring( COLLECTION_PREFIX.length(), payload.lastIndexOf(COLLECTION_SUFFIX));
+ }
+ return s;
+ }
+
+ public void destroy()
+ {
+
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/util/GWTJsonFilter.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/web.xml
===================================================================
--- projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/web.xml 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/web.xml 2008-11-19 13:04:27 UTC (rev 2996)
@@ -16,13 +16,13 @@
</context-param>
<context-param>
- <param-name>org.jboss.bpm.console.server.dao.DAOFactory</param-name>
- <param-value>org.jboss.bpm.console.server.dao.internal.JBPM3DAOFactory</param-value>
+ <param-name>org.jboss.bpm.console.server.dao.ManagementFactory</param-name>
+ <param-value>org.jboss.bpm.console.server.dao.internal.JBPM3ManagementFactory</param-value>
</context-param>
<filter>
<filter-name>gwtJSON</filter-name>
- <filter-class>org.jboss.bpm.console.server.GWTJsonFilter</filter-class>
+ <filter-class>org.jboss.bpm.console.server.util.GWTJsonFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>gwtJSON</filter-name>
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/UIConstants.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/UIConstants.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/UIConstants.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -33,4 +33,6 @@
public static final int EDITOR_WIDTH = 680;
public static final int TEASER_PANEL_WIDTH = 200;
public static final int EDITOR_PANEL_WIDTH = 450;
+
+ public static final String DEFAULT_TRANSITION = "(Default transition)";
}
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -39,7 +39,7 @@
this.consoleServerUrl = consoleServerUrl;
this.webContext = webContext;
- Log.debug("Using gwt-console-server: " + consoleServerUrl + "/" +webContext);
+ Log.debug("Using gwt-console-server: " + getBaseUrl());
}
public String getConsoleServerUrl()
@@ -76,7 +76,7 @@
if(i<possibleRoles.length-1)
sb.append(",");
}
- return getBaseUrl() + "/rs/user/roles?roleCheck="+sb.toString();
+ return getBaseUrl() + "/rs/identity/user/roles?roleCheck="+sb.toString();
}
@Deprecated
@@ -151,4 +151,10 @@
String encodedSignal = URL.encode(signal);
return getBaseUrl() + "/rs/jbpm3/tokens/"+tok.getId()+"/transition?signal="+encodedSignal;
}
+
+ public String getGroupsForActorUrl(String actorId)
+ {
+ return getBaseUrl() + "/rs/identity/user/"+actorId+"/groups";
+ }
+
}
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -239,4 +239,24 @@
return rt;
}
+ public static List<String> parseStringArray(JSONValue jso)
+ {
+ List<String> result = new ArrayList<String>();
+
+ JSONArray jsonArray = jso.isArray();
+
+ if(null==jsonArray)
+ throw new IllegalArgumentException("Not an array: " +jso);
+
+ for(int i=0; i<jsonArray.size(); i++)
+ {
+ JSONValue jsonValue = jsonArray.get(i);
+ if(jsonValue.toString().equals("null"))
+ continue; // TODO: JBPM-1828
+ JSONString item = jsonValue.isString();
+ result.add(item.stringValue());
+ }
+
+ return result;
+ }
}
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -44,10 +44,7 @@
import org.jboss.bpm.console.client.model.ProcessDefinition;
import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.model.jbpm3.TokenReference;
-import org.jboss.bpm.console.client.widgets.HelpPanel;
-import org.jboss.bpm.console.client.widgets.TeaserPanel;
-import org.jboss.bpm.console.client.widgets.TokenEditor;
-import org.jboss.bpm.console.client.widgets.TokenForm;
+import org.jboss.bpm.console.client.widgets.*;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
@@ -137,7 +134,7 @@
// ---------------
- detailsForm = createBaseFormPanel();
+ detailsForm = FormWidgets.createBaseFormPanel();
// ---------------
@@ -230,23 +227,12 @@
return outerFormPanel;
}
- private FormPanel createBaseFormPanel()
- {
- final FormPanel formPanel = new FormPanel();
- formPanel.setLabelAlign(Position.LEFT);
- formPanel.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
- formPanel.setHeader(false);
- formPanel.setFrame(false);
- formPanel.setBorder(false);
- formPanel.setPaddings(5, 5, 5, 0);
- formPanel.setLabelWidth(120);
- return formPanel;
- }
+
private void remoteSignal(TokenReference tok, String signal)
{
- String url = signal.equals(TokenForm.DEFAULT_TRANSITION) ?
+ String url = signal.equals(UIConstants.DEFAULT_TRANSITION) ?
view.getUrlBuilder().getTokenSignalUrl(tok) :
view.getUrlBuilder().getTokenSignalUrl(tok, signal);
Added: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentCallback.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentCallback.java (rev 0)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentCallback.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,30 @@
+/*
+ * 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.task;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface AssignmentCallback
+{
+ void onAssignmentDone();
+}
Added: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentFormPanel.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentFormPanel.java (rev 0)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/AssignmentFormPanel.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,180 @@
+/*
+ * 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.task;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.http.client.*;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONValue;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.data.Record;
+import com.gwtext.client.widgets.*;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.event.PanelListenerAdapter;
+import com.gwtext.client.widgets.form.Form;
+import com.gwtext.client.widgets.form.FormPanel;
+import org.jboss.bpm.console.client.MainView;
+import org.jboss.bpm.console.client.model.DTOParser;
+import org.jboss.bpm.console.client.model.TaskReference;
+import org.jboss.bpm.console.client.widgets.FormWidgets;
+import org.jboss.bpm.console.client.widgets.ModelChangeListener;
+import org.jboss.bpm.console.client.widgets.ModelListenerRegistry;
+import org.jboss.bpm.console.client.widgets.RefreshableComboBox;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class AssignmentFormPanel extends Panel implements ModelChangeListener
+{
+ private FormPanel formPanel;
+
+ private MainView mainView;
+ private AssignmentCallback callback;
+
+ private List<String> selectedGroups;
+
+ public AssignmentFormPanel(MainView mainView, AssignmentCallback callback)
+ {
+ super();
+ this.mainView = mainView;
+ this.callback = callback;
+
+ setTitle("Assigment");
+ setBorder(false);
+ setFrame(false);
+
+ // ---------------
+
+ formPanel = FormWidgets.createBaseFormPanel();
+ RefreshableComboBox cb = new RefreshableComboBox("actorId", "Actor");
+ formPanel.add(cb);
+
+ final Button assignBtn = new Button("Assign",
+ new ButtonListenerAdapter()
+ {
+
+ public void onClick(Button button, EventObject eventObject)
+ {
+
+ Form form = formPanel.getForm();
+ RefreshableComboBox cb = (RefreshableComboBox)form.findField("actorId");
+ String rawValue = cb.getRawValue();
+
+ if(null==rawValue || rawValue.equals(""))
+ {
+ MessageBox.alert("Please select an actor.");
+ return;
+ }
+
+ // TODO: implement
+ Log.debug("Assign to " + rawValue);
+
+ }
+ }
+ );
+
+ formPanel.add(assignBtn);
+ this.add(formPanel);
+
+ // ---------------
+ this.addListener(
+ new PanelListenerAdapter()
+ {
+
+
+ public void onAfterLayout(Container container)
+ {
+ refreshComboBox();
+ }
+ }
+ );
+
+ }
+
+
+ public void onModelChange(ModelListenerRegistry parent, Object changeEvent)
+ {
+ TaskListEditor editor = (TaskListEditor)parent.getUnderlying();
+ TaskReference taskRef = (TaskReference)changeEvent;
+
+ Log.debug("onModelChange " + taskRef);
+ selectedGroups = null;
+
+ String resourceUrl = mainView.getUrlBuilder().getGroupsForActorUrl(mainView.getUsername());
+ updateAssigmentForm(resourceUrl);
+ }
+
+
+ public void onRecordChange(ModelListenerRegistry parent, Record record)
+ {
+ // ignore
+ }
+
+ private void updateAssigmentForm(String url)
+ {
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url );
+
+ try
+ {
+ rb.sendRequest(null,
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ if(200 != response.getStatusCode())
+ Log.error("Failed to retrieve groups: " + response.getStatusText());
+
+ JSONValue value = JSONParser.parse(response.getText());
+
+ selectedGroups = DTOParser.parseStringArray(value);
+
+ if(isRendered())
+ refreshComboBox();
+
+ Log.debug("Update from " + selectedGroups);
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // Unknown error
+ Log.error("Unknown error", t);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ Log.error("Request failed" ,e1);
+ }
+ }
+
+ private void refreshComboBox()
+ {
+ if(null==selectedGroups)
+ throw new IllegalArgumentException("Group list cannot be null");
+
+ Form form = formPanel.getForm();
+ RefreshableComboBox cb = (RefreshableComboBox)form.findField("actorId");
+ cb.display(selectedGroups);
+ }
+}
Added: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/DetailsFormPanel.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/DetailsFormPanel.java (rev 0)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/DetailsFormPanel.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,274 @@
+/*
+ * 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.task;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.http.client.*;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.data.Record;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.MessageBox;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.ComboBox;
+import com.gwtext.client.widgets.form.Form;
+import com.gwtext.client.widgets.form.FormPanel;
+import com.gwtext.client.widgets.form.TextField;
+import org.jboss.bpm.console.client.MainView;
+import org.jboss.bpm.console.client.UIConstants;
+import org.jboss.bpm.console.client.model.TaskReference;
+import org.jboss.bpm.console.client.widgets.FormWidgets;
+import org.jboss.bpm.console.client.widgets.ModelChangeListener;
+import org.jboss.bpm.console.client.widgets.ModelListenerRegistry;
+import org.jboss.bpm.console.client.widgets.RefreshableComboBox;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class DetailsFormPanel extends Panel implements ModelChangeListener
+{
+
+ private FormPanel formPanel;
+ private TaskReference selectedInstance;
+ private MainView mainView;
+
+ private Button startBtn;
+ private Button stopBtn;
+ private Button endBtn;
+
+ private AssignmentCallback callback;
+
+ public DetailsFormPanel(final MainView mainView, AssignmentCallback callback)
+ {
+ super();
+ this.mainView = mainView;
+ this.callback = callback;
+
+ setTitle("Task Details");
+ setBorder(false);
+ setFrame(false);
+
+ // ---------------
+
+ formPanel = FormWidgets.createBaseFormPanel();
+
+ //the field names must match the data field values from the Store
+ TextField idField = new TextField("Id", "id", 230);
+ idField.setReadOnly(true);
+ formPanel.add(idField);
+
+ TextField nameField = new TextField("Name", "name", 230);
+ nameField.setReadOnly(true);
+ formPanel.add(nameField);
+
+ TextField actorField = new TextField("Actor", "actor", 230);
+ actorField.setReadOnly(true);
+ formPanel.add(actorField);
+
+ TextField stateField = new TextField("State", "currentState", 230);
+ stateField.setReadOnly(true);
+ formPanel.add(stateField);
+
+ // ----------
+ RefreshableComboBox cb = new RefreshableComboBox("signal", "End signal");
+ formPanel.add(cb);
+
+ startBtn = new Button("Assign current user",
+ new ButtonListenerAdapter()
+ {
+
+ public void onClick(Button button, EventObject eventObject)
+ {
+ if(null==selectedInstance)
+ {
+ MessageBox.alert("Please select a task.");
+ return;
+ }
+ selectedInstance.setActor(mainView.getUsername());
+ reassignTask();
+ }
+ }
+ );
+
+ stopBtn = new Button("Release",
+ new ButtonListenerAdapter()
+ {
+
+ public void onClick(Button button, EventObject eventObject)
+ {
+ if(null==selectedInstance)
+ {
+ MessageBox.alert("Please select a task.");
+ return;
+ }
+ selectedInstance.setActor(null);
+ reassignTask();
+ }
+ }
+ );
+
+ endBtn = new Button("End",
+ new ButtonListenerAdapter()
+ {
+
+ public void onClick(Button button, EventObject eventObject)
+ {
+ if(null==selectedInstance)
+ {
+ MessageBox.alert("Please select a task.");
+ return;
+ }
+
+ selectedInstance.close();
+
+ ComboBox cb = (ComboBox) formPanel.getForm().findField("signal");
+ String signalName = cb.getRawValue();
+ if(signalName.equals(""))
+ MessageBox.alert("Please select a signal to end this task");
+ else
+ endTask(signalName);
+ }
+ }
+ );
+
+ formPanel.addButton(startBtn);
+ formPanel.addButton(stopBtn);
+ formPanel.addButton(endBtn);
+
+ this.add(formPanel);
+ }
+
+ private void reassignTask()
+ {
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,
+ mainView.getUrlBuilder().getTaskAssignmentURL(
+ selectedInstance.getId(), selectedInstance.getActor()
+ )
+ );
+
+ try
+ {
+ rb.sendRequest("",
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ if(200 != response.getStatusCode())
+ Log.error("Failed to reassign task: " + response.getStatusText());
+
+ selectedInstance = null;
+ callback.onAssignmentDone();
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // Unknown error
+ Log.error("Unknown error", t);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ Log.error("Request failed" ,e1);
+ }
+ }
+
+ private void endTask(String signalName)
+ {
+ String taskCloseURL = signalName.equals(UIConstants.DEFAULT_TRANSITION) ?
+ mainView.getUrlBuilder().getTaskEndURL(selectedInstance.getId()) :
+ mainView.getUrlBuilder().getTaskEndURL(selectedInstance.getId(), signalName);
+
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,
+ taskCloseURL
+ );
+
+ Log.debug(taskCloseURL);
+
+ try
+ {
+ rb.sendRequest("",
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ if(200 != response.getStatusCode())
+ Log.error("Failed to end task: " + response.getStatusText());
+
+ selectedInstance = null;
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // Unknown error
+ Log.error("Unknown error", t);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ Log.error("Failed to close task", e1);
+ }
+ }
+
+
+ public void onRecordChange(ModelListenerRegistry parent, Record changeEvent)
+ {
+ TaskListEditor editor = (TaskListEditor)parent.getUnderlying();
+ selectedInstance = TaskList.transform(changeEvent);
+
+ Form form = formPanel.getForm();
+ RefreshableComboBox cb = (RefreshableComboBox)form.findField("signal");
+
+ if(!selectedInstance.hasPooledActors())
+ {
+ // no group assignment available
+ startBtn.disable();
+ stopBtn.disable();
+ }
+ else if(TaskReference.STATE.IN_PROGRESS == selectedInstance.getCurrentState())
+ {
+ startBtn.disable();
+ stopBtn.enable();
+ cb.enable();
+ endBtn.enable();
+ }
+ else
+ {
+ startBtn.enable();
+ stopBtn.disable();
+ cb.disable();
+ endBtn.disable();
+ }
+
+ cb.display( selectedInstance.getTransitionNames() );
+
+ formPanel.getForm().loadRecord(changeEvent);
+ formPanel.doLayout();
+ }
+
+
+ public void onModelChange(ModelListenerRegistry parent, Object changeEvent)
+ {
+ // ignore
+ }
+}
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/task/TaskListEditor.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -21,18 +21,12 @@
*/
package org.jboss.bpm.console.client.task;
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.http.client.*;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.core.Position;
-import com.gwtext.client.data.*;
-import com.gwtext.client.widgets.*;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.data.Record;
+import com.gwtext.client.widgets.Component;
+import com.gwtext.client.widgets.PaddedPanel;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.event.PanelListenerAdapter;
-import com.gwtext.client.widgets.form.FormPanel;
-import com.gwtext.client.widgets.form.TextField;
-import com.gwtext.client.widgets.form.ComboBox;
-import com.gwtext.client.widgets.form.Form;
import com.gwtext.client.widgets.grid.RowSelectionModel;
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
import com.gwtext.client.widgets.layout.ColumnLayout;
@@ -41,15 +35,14 @@
import org.jboss.bpm.console.client.MainView;
import org.jboss.bpm.console.client.UIConstants;
import org.jboss.bpm.console.client.model.TaskReference;
+import org.jboss.bpm.console.client.widgets.ModelChangeListener;
+import org.jboss.bpm.console.client.widgets.ModelListenerRegistry;
import org.jboss.bpm.console.client.widgets.TeaserPanel;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class TaskListEditor extends Editor
+public class TaskListEditor extends Editor implements AssignmentCallback
{
public final static String ID = "org.jboss.bpm.task.TaskList";
@@ -57,37 +50,24 @@
private TaskList taskList;
private Panel teaserPanel;
private boolean initialized;
-
- private Panel formContainer;
-
- private TaskReference selectedInstance;
-
private TabPanel tabPanel;
- private FormPanel formPanel;
+ private ModelListenerRegistry modelListeners;
-
- public static final String DEFAULT_TRANSITION = "(Default transition)";
-
- final ArrayReader reader = new ArrayReader(new RecordDef(
- new FieldDef[]{
- new StringFieldDef("signal")
- }
- ));
-
- public TaskListEditor(MainView mainView )
+ public TaskListEditor(MainView mainView)
{
super();
this.setId(ID);
this.mainView = mainView;
+ this.modelListeners = new ModelListenerRegistry(this);
+
this.setLayout( new ColumnLayout() );
this.setWidth(UIConstants.EDITOR_WIDTH);
this.addListener(
new PanelListenerAdapter()
{
-
public boolean doBeforeRender(Component component)
{
return beforeRenderCallback();
@@ -126,7 +106,7 @@
leftHand.setBorder(false);
// ----------------------------------
-
+
tabPanel = new TabPanel();
tabPanel.setPaddings(10);
tabPanel.setPlain(true);
@@ -138,27 +118,42 @@
// ----------------------------------
taskList = new TaskList("Task overview", mainView);
+ final RowSelectionModel sm = new RowSelectionModel(true);
+ sm.addListener(
+ new RowSelectionListenerAdapter()
+ {
+ public void onRowSelect(RowSelectionModel sm, int rowIndex, Record record)
+ {
+ TaskReference taskRef = TaskList.transform(record);
+ modelListeners.fireRecordChangeEvent(record);
+ modelListeners.fireModelChangeEvent(taskRef);
+ }
+ }
+ );
+ taskList.setRowSelectionModel(sm);
leftHand.add(taskList);
// ----------------------------------
- Panel detailsFormPanel = assembleDetailsForm();
- tabPanel.add(detailsFormPanel);
- tabPanel.add( new Panel("Assignment") );
+ Panel detailsPanel = new DetailsFormPanel(mainView, this);
+ Panel assignmentPanel = new AssignmentFormPanel(mainView, this);
- formContainer = new Panel("Data");
- formContainer.setPaddings(10);
- formContainer.setBorder(false);
- //tabPanel.add(formContainer);
+ modelListeners.addListener((ModelChangeListener)detailsPanel);
+ modelListeners.addListener((ModelChangeListener)assignmentPanel);
+ tabPanel.add( detailsPanel );
+ tabPanel.add( assignmentPanel );
+
+ // ----------------------------------
+
leftHand.add(tabPadding);
// ----------------------------------
teaserPanel = new TeaserPanel();
- // ----------------------------------
-
+ // ----------------------------------
+
this.add(leftHand, new ColumnLayoutData(0.7) );
this.add(teaserPanel , new ColumnLayoutData(0.3) );
@@ -170,373 +165,8 @@
return true;
}
- public Panel getFormContainer()
+ public void onAssignmentDone()
{
- return formContainer;
+ taskList.reloadStore();
}
-
- private Panel assembleDetailsForm()
- {
- // ---------------
-
- Panel outerFormPanel = new Panel();
- outerFormPanel.setTitle("Task Details");
- outerFormPanel.setBorder(false);
- outerFormPanel.setFrame(false);
-
- // ---------------
-
- formPanel = new FormPanel();
- formPanel.setLabelAlign(Position.LEFT);
- formPanel.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
- formPanel.setHeader(false);
- formPanel.setFrame(false);
- formPanel.setBorder(false);
- formPanel.setPaddings(5, 5, 5, 0);
- formPanel.setLabelWidth(120);
-
- //the field names must match the data field values from the Store
- TextField idField = new TextField("Id", "id", 230);
- idField.setReadOnly(true);
- formPanel.add(idField);
-
- TextField nameField = new TextField("Name", "name", 230);
- nameField.setReadOnly(true);
- formPanel.add(nameField);
-
- TextField actorField = new TextField("Actor", "actor", 230);
- actorField.setReadOnly(true);
- formPanel.add(actorField);
-
- TextField stateField = new TextField("State", "currentState", 230);
- stateField.setReadOnly(true);
- formPanel.add(stateField);
-
- // ----------
- MemoryProxy dataProxy = createMemoryProxy(new ArrayList<String>());
- Store store = new Store(dataProxy, reader);
- store.load();
-
- ComboBox cb = new ComboBox();
- cb.setFieldLabel("End signal");
- cb.setHiddenName("signal");
- cb.setStore(store);
- cb.setDisplayField("signal");
- cb.setMode(ComboBox.LOCAL);
- cb.setTriggerAction(ComboBox.ALL);
- cb.setEmptyText("");
- cb.setSelectOnFocus(true);
- cb.setWidth(190);
- cb.setEditable(false);
- formPanel.add(cb);
-
- final Button startBtn = new Button("Assign current user",
- new ButtonListenerAdapter()
- {
-
- public void onClick(Button button, EventObject eventObject)
- {
- if(null==selectedInstance)
- {
- MessageBox.alert("Please select a task.");
- return;
- }
- selectedInstance.setActor(mainView.getUsername());
- reassignTask();
- }
- }
- );
-
- final Button stopBtn = new Button("Release",
- new ButtonListenerAdapter()
- {
-
- public void onClick(Button button, EventObject eventObject)
- {
- if(null==selectedInstance)
- {
- MessageBox.alert("Please select a task.");
- return;
- }
- selectedInstance.setActor(null);
- reassignTask();
- }
- }
- );
-
- final Button endBtn = new Button("End",
- new ButtonListenerAdapter()
- {
-
- public void onClick(Button button, EventObject eventObject)
- {
- if(null==selectedInstance)
- {
- MessageBox.alert("Please select a task.");
- return;
- }
-
- selectedInstance.close();
-
- ComboBox cb = (ComboBox)formPanel.getForm().findField("signal");
- String signalName = cb.getRawValue();
- if(signalName.equals(""))
- MessageBox.alert("Please select a signal to end this task");
- else
- endTask(signalName);
- }
- }
- );
-
-
- /*Button examineButton = new Button("Examine", new ButtonListenerAdapter()
- {
- public void onClick(Button button, EventObject e)
- {
- if (null == selectedInstance)
- MessageBox.alert("Please select a process.");
- else
- onExamine(selectedInstance);
- }
- });
- examineButton.setTooltip("Examine");
- formPanel.add(examineButton);
- */
-
- formPanel.addButton(startBtn);
- formPanel.addButton(stopBtn);
-
-
- formPanel.addButton(endBtn);
-
-
- // ----------------
-
- final RowSelectionModel sm = new RowSelectionModel(true);
- sm.addListener(
- new RowSelectionListenerAdapter()
- {
- public void onRowSelect(RowSelectionModel sm, int rowIndex, Record record)
- {
- selectedInstance = TaskList.transform(record);
- Form form = formPanel.getForm();
- ComboBox signals = (ComboBox)form.findField("signal");
-
- if(!selectedInstance.hasPooledActors())
- {
- // no group assignment available
- startBtn.disable();
- stopBtn.disable();
- }
- else if(TaskReference.STATE.IN_PROGRESS == selectedInstance.getCurrentState())
- {
- startBtn.disable();
- stopBtn.enable();
- signals.enable();
- endBtn.enable();
- }
- else
- {
- startBtn.enable();
- stopBtn.disable();
- signals.disable();
- endBtn.disable();
- }
-
- // refresh combo box
-
- signals.reset();
-
- MemoryProxy dataProxy = createMemoryProxy(selectedInstance.getTransitionNames());
- Store store = new Store(dataProxy, reader);
- store.load();
- signals.setStore(store);
-
- formPanel.getForm().loadRecord(record);
- formPanel.doLayout();
- }
- }
- );
- taskList.setRowSelectionModel(sm);
-
- outerFormPanel.add(formPanel);
-
- return outerFormPanel;
- }
-
- private void reassignTask()
- {
- RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,
- mainView.getUrlBuilder().getTaskAssignmentURL(
- selectedInstance.getId(), selectedInstance.getActor()
- )
- );
-
- try
- {
- rb.sendRequest("",
- new RequestCallback() {
-
- public void onResponseReceived(Request request, Response response)
- {
- if(200 != response.getStatusCode())
- Log.error("Failed to reassign task: " + response.getStatusText());
-
- taskList.reloadStore();
- selectedInstance = null;
- }
-
- public void onError(Request request, Throwable t)
- {
- // Unknown error
- Log.error("Unknown error", t);
- }
- });
- }
- catch (RequestException e1)
- {
- Log.error("Request failed" ,e1);
- }
- }
-
- private void endTask(String signalName)
- {
- String taskCloseURL = signalName.equals(DEFAULT_TRANSITION) ?
- mainView.getUrlBuilder().getTaskEndURL(selectedInstance.getId()) :
- mainView.getUrlBuilder().getTaskEndURL(selectedInstance.getId(), signalName);
-
- RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,
- taskCloseURL
- );
-
- Log.debug(taskCloseURL);
-
- try
- {
- rb.sendRequest("",
- new RequestCallback() {
-
- public void onResponseReceived(Request request, Response response)
- {
- if(200 != response.getStatusCode())
- Log.error("Failed to end task: " + response.getStatusText());
-
- taskList.reloadStore();
- selectedInstance = null;
- }
-
- public void onError(Request request, Throwable t)
- {
- // Unknown error
- Log.error("Unknown error", t);
- }
- });
- }
- catch (RequestException e1)
- {
- Log.error("Failed to close task", e1);
- }
- }
-
- /*protected void onExamine(final TaskReference selectedInstance)
- {
- String url = mainView.getUrlBuilder().getTaskFormDefURL(
- selectedInstance.getProcessId(), selectedInstance.getId());
-
- MessageBox.show(new MessageBoxConfig() {
- {
- setMsg("Generate form, please wait.");
- setProgressText("Loading...");
- setWidth(300);
- setWait(true);
- setWaitConfig(new WaitConfig() {
- {
- setInterval(200);
- }
- });
- }
- });
-
- JSONRequest.get(url,
- new JSONRequestHandler() {
-
- public void onRequestComplete(JavaScriptObject json)
- {
- JSONObject root = new JSONObject(json);
- FormDef formDef = null;
- try
- {
- formDef = DTOParser.parseFormDef(root);
- }
- catch (Throwable e)
- {
- Log.error("FormDef parsing failed", e);
- }
-
- MessageBox.hide();
-
- // generate form
- FormPanel formPanel = new FormPanel();
-
- // -----------
-
- FieldSet fieldSet = new FieldSet();
- fieldSet.setLabelWidth(90);
- fieldSet.setTitle(selectedInstance.getName());
- fieldSet.setAutoHeight(true);
- fieldSet.setBorder(false);
-
- // -----------
- for(org.jboss.bpm.console.client.model.forms.FieldDef fieldDef : formDef.getFields())
- {
- switch(fieldDef.getInputType())
- {
- case TEXT:
- fieldSet.add( new TextField(fieldDef.getLabel(), fieldDef.getVarname()) );
- break;
- case TEXTAREA:
- fieldSet.add( new TextArea(fieldDef.getLabel(), fieldDef.getVarname()));
- break;
- case BOOL:
- fieldSet.add( new Radio(fieldDef.getLabel(), fieldDef.getVarname()));
- break;
- default:
- Log.debug("Unknown input type:" + fieldDef.getInputType());
- }
- }
-
- // -----------
-
- Panel inner = new PaddedPanel(fieldSet, 0, 10, 0, 0);
- formPanel.add(inner);
-
- // -----------
- displayForm(formPanel);
- }
- }
- );
- }
-
- private void displayForm(FormPanel formPanel)
- {
-
- final Window window = new Window();
- window.setTitle("Task form");
- window.setClosable(true);
- window.setWidth(320);
- window.setHeight(240);
- window.setPlain(true);
- window.setCloseAction(Window.HIDE);
- window.add( formPanel );
- window.show("");
- } */
-
- private MemoryProxy createMemoryProxy(List signals)
- {
- if(signals.isEmpty())
- signals.add(DEFAULT_TRANSITION);
- return new MemoryProxy(
- new Object[][]{ signals.toArray()}
- );
- }
}
Added: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/FormWidgets.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/FormWidgets.java (rev 0)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/FormWidgets.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,47 @@
+/*
+ * 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.widgets;
+
+import com.gwtext.client.core.Position;
+import com.gwtext.client.widgets.form.FormPanel;
+import org.jboss.bpm.console.client.UIConstants;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class FormWidgets
+{
+ public static FormPanel createBaseFormPanel()
+ {
+ final FormPanel formPanel = new FormPanel();
+ formPanel.setLabelAlign(Position.LEFT);
+ formPanel.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
+ formPanel.setHeader(false);
+ formPanel.setFrame(false);
+ formPanel.setBorder(false);
+ formPanel.setPaddings(5, 5, 5, 0);
+ formPanel.setLabelWidth(120);
+ return formPanel;
+ }
+
+
+}
Added: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelChangeListener.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelChangeListener.java (rev 0)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelChangeListener.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,33 @@
+/*
+ * 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.widgets;
+
+import com.gwtext.client.data.Record;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface ModelChangeListener
+{
+ void onModelChange(ModelListenerRegistry parent, Object changeEvent);
+ void onRecordChange(ModelListenerRegistry parent, Record record);
+}
Added: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelListenerRegistry.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelListenerRegistry.java (rev 0)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/ModelListenerRegistry.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,70 @@
+/*
+ * 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.widgets;
+
+import com.gwtext.client.data.Record;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Utility to propaget model change events across widgets
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ModelListenerRegistry
+{
+ private List<ModelChangeListener> listeners = new ArrayList<ModelChangeListener>();
+
+ private Object underlying;
+
+ public ModelListenerRegistry(Object underlying)
+ {
+ this.underlying = underlying;
+ }
+
+ public void addListener(ModelChangeListener listener)
+ {
+ this.listeners.add(listener);
+ }
+
+ public void fireRecordChangeEvent(Record record)
+ {
+ for(ModelChangeListener l : listeners)
+ {
+ l.onRecordChange(this, record);
+ }
+ }
+
+ public void fireModelChangeEvent(Object event)
+ {
+ for(ModelChangeListener l : listeners)
+ {
+ l.onModelChange(this, event);
+ }
+ }
+
+ public Object getUnderlying()
+ {
+ return underlying;
+ }
+}
Added: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/RefreshableComboBox.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/RefreshableComboBox.java (rev 0)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/RefreshableComboBox.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -0,0 +1,90 @@
+/*
+ * 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.widgets;
+
+import com.gwtext.client.widgets.form.ComboBox;
+import com.gwtext.client.data.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.bpm.console.client.UIConstants;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class RefreshableComboBox extends ComboBox
+{
+
+ private final Reader reader;
+
+ public RefreshableComboBox(String fieldName, String label)
+ {
+ super();
+ this.reader = new ArrayReader(new RecordDef(
+ new FieldDef[]{
+ new StringFieldDef(fieldName)
+ }
+ ));
+
+ MemoryProxy dataProxy = createMemoryProxy(new ArrayList<String>());
+ Store store = new Store(dataProxy, reader);
+ store.load();
+
+ setFieldLabel(label);
+ setHiddenName(fieldName);
+ setStore(store);
+ setDisplayField(fieldName);
+ setMode(ComboBox.LOCAL);
+ setTriggerAction(ComboBox.ALL);
+ setEmptyText("");
+ setSelectOnFocus(true);
+ setWidth(190);
+ setEditable(false);
+ }
+
+ private MemoryProxy createMemoryProxy(List<String> items)
+ {
+ if(items.isEmpty())
+ items.add(UIConstants.DEFAULT_TRANSITION);
+
+ Object[][] objs = new Object[items.size()][];
+ int i=0;
+ for(String s : items)
+ {
+ objs[i] = new Object[]{s};
+ i++;
+ }
+
+ return new MemoryProxy(objs);
+ }
+
+ public void display(List<String> items)
+ {
+ super.reset();
+
+ MemoryProxy dataProxy = createMemoryProxy(items);
+ Store store = new Store(dataProxy, reader);
+ store.load();
+ super.setStore(store);
+ }
+}
\ No newline at end of file
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenEditor.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenEditor.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenEditor.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -24,7 +24,6 @@
import com.gwtext.client.core.EventObject;
import com.gwtext.client.data.Node;
import com.gwtext.client.widgets.Panel;
-import com.gwtext.client.widgets.layout.HorizontalLayout;
import com.gwtext.client.widgets.layout.ColumnLayout;
import com.gwtext.client.widgets.layout.ColumnLayoutData;
import com.gwtext.client.widgets.tree.TreeNode;
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenForm.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenForm.java 2008-11-19 12:54:44 UTC (rev 2995)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/widgets/TokenForm.java 2008-11-19 13:04:27 UTC (rev 2996)
@@ -23,7 +23,6 @@
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Position;
-import com.gwtext.client.data.*;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.Panel;
@@ -36,9 +35,6 @@
import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.model.jbpm3.TokenReference;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
@@ -46,15 +42,8 @@
{
private final FormPanel tokenForm;
private final Button signalButton;
- final ArrayReader reader = new ArrayReader(new RecordDef(
- new FieldDef[]{
- new StringFieldDef("signal")
- }
- ));
-
private TokenReference lastSelectedToken;
- public static final String DEFAULT_TRANSITION = "(Default transition)";
-
+
public TokenForm(final TokenEditor.SignalCallback callback)
{
super();
@@ -85,21 +74,7 @@
// ----------
- MemoryProxy dataProxy = createMemoryProxy(new ArrayList<String>());
- Store store = new Store(dataProxy, reader);
- store.load();
-
- ComboBox cb = new ComboBox();
- cb.setFieldLabel("Signal");
- cb.setHiddenName("signal");
- cb.setStore(store);
- cb.setDisplayField("signal");
- cb.setMode(ComboBox.LOCAL);
- cb.setTriggerAction(ComboBox.ALL);
- cb.setEmptyText("");
- cb.setSelectOnFocus(true);
- cb.setWidth(190);
- cb.setEditable(false);
+ RefreshableComboBox cb = new RefreshableComboBox("signal", "Signal");
tokenForm.add(cb);
final ButtonListenerAdapter listenerAdapter = new ButtonListenerAdapter()
@@ -147,15 +122,11 @@
form.findField("id").setRawValue(tok.getId()+"");
form.findField("nodeName").setRawValue(tok.getCurrentNodeName());
- // refresh combo box
- ComboBox cb = (ComboBox)form.findField("signal");
+ // display combo box
+ RefreshableComboBox cb = (RefreshableComboBox)form.findField("signal");
cb.reset();
-
- MemoryProxy dataProxy = createMemoryProxy(tok.getAvailableSignals());
- Store store = new Store(dataProxy, reader);
- store.load();
- cb.setStore(store);
-
+ cb.display( tok.getAvailableSignals());
+
// suspended instances cannot be signaled
if(processInstance.isSuspended() || !tok.canBeSignaled())
{
@@ -174,16 +145,7 @@
lastSelectedToken = tok;
}
-
- private MemoryProxy createMemoryProxy(List signals)
- {
- if(signals.isEmpty())
- signals.add(DEFAULT_TRANSITION);
- return new MemoryProxy(
- new Object[][]{ signals.toArray()}
- );
- }
-
+
public void resetForm()
{
tokenForm.getForm().reset();
More information about the jbpm-commits
mailing list