[jbpm-commits] JBoss JBPM SVN: r3074 - in projects/gwt-console/trunk/server: src/main/java/org/jboss/bpm/console/server and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Nov 25 06:05:53 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-11-25 06:05:53 -0500 (Tue, 25 Nov 2008)
New Revision: 3074
Added:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/DiagramInfoParser.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetGroupMembershipCommand.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetUsersForGroupCommand.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3CommandDelegate.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3FormParser.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementExtension.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementFactory.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ProcessManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3TaskManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3UserManagement.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/Transform.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/cmd/
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ProcessManagementImpl.java
Removed:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/cmd/GetGroupMembershipCommand.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/cmd/GetUsersForGroupCommand.java
Modified:
projects/gwt-console/trunk/server/pom.xml
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/integration/ManagementFactory.java
Log:
Add jBPM spec integration
Modified: projects/gwt-console/trunk/server/pom.xml
===================================================================
--- projects/gwt-console/trunk/server/pom.xml 2008-11-25 10:29:55 UTC (rev 3073)
+++ projects/gwt-console/trunk/server/pom.xml 2008-11-25 11:05:53 UTC (rev 3074)
@@ -18,7 +18,6 @@
</parent>
<dependencies>
-
<!-- Module -->
<dependency>
<groupId>org.jbpm.jbpm3</groupId>
@@ -42,8 +41,13 @@
<artifactId>jbpm-identity</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-spec-api</artifactId>
+ <version>${version}</version>
+ <scope>provided</scope>
+ </dependency>
-
<!-- GWT related -->
<dependency>
<groupId>com.google.gwt</groupId>
Modified: 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/TaskMgmtFacade.java 2008-11-25 10:29:55 UTC (rev 3073)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -32,7 +32,7 @@
import org.jboss.bpm.console.server.integration.JBPM3Extension;
import org.jboss.bpm.console.server.integration.ManagementFactory;
import org.jboss.bpm.console.server.integration.TaskManagement;
-import org.jboss.bpm.console.server.integration.internal.JBPM3FormParser;
+import org.jboss.bpm.console.server.integration.jbpm3.JBPM3FormParser;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/ManagementFactory.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/ManagementFactory.java 2008-11-25 10:29:55 UTC (rev 3073)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/ManagementFactory.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -25,7 +25,7 @@
/**
* Construct management implementations.
- * Defaults to <code>org.jboss.bpm.console.server.integration.internal.JBPM3ManagementFactory</code>
+ * Defaults to <code>org.jboss.bpm.console.server.integration.jbpm3.JBPM3ManagementFactory</code>
*
* @see org.jboss.bpm.console.server.util.ServiceLoader
*
@@ -33,7 +33,7 @@
*/
public abstract class ManagementFactory
{
- private static final String DEFAULT_FACTORY = "org.jboss.bpm.console.server.integration.internal.JBPM3ManagementFactory";
+ private static final String DEFAULT_FACTORY = "org.jboss.bpm.console.server.integration.jbpm3.JBPM3ManagementFactory";
public abstract ProcessManagement createProcessManagement();
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/DiagramInfoParser.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/DiagramInfoParser.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/DiagramInfoParser.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/DiagramInfoParser.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,91 @@
+/*
+ * 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.integration.jbpm3;
+
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramNodeInfo;
+import org.jbpm.util.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class DiagramInfoParser
+{
+ /**
+ * Will close the stream after successfull read
+ * @param in
+ * @return
+ */
+ public static DiagramInfo parse(InputStream in )
+ {
+ Document document = XmlUtil.parseXmlInputStream(in);
+ Element processDiagramElement = document.getDocumentElement();
+ final String widthString = processDiagramElement.getAttribute("width");
+ final String heightString = processDiagramElement.getAttribute("height");
+ final List<DiagramNodeInfo> diagramNodeInfoList = new ArrayList<DiagramNodeInfo>();
+ final NodeList nodeNodeList = processDiagramElement.getElementsByTagName("node");
+ final int nodeNodeListLength = nodeNodeList.getLength();
+ for (int i = 0; i < nodeNodeListLength; i ++) {
+ final Node nodeNode = nodeNodeList.item(i);
+ if (nodeNode instanceof Node && nodeNode.getParentNode() == processDiagramElement) {
+ final Element nodeElement = (Element) nodeNode;
+ final String nodeName = nodeElement.getAttribute("name");
+ final String nodeXString = nodeElement.getAttribute("x");
+ final String nodeYString = nodeElement.getAttribute("y");
+ final String nodeWidthString = nodeElement.getAttribute("width");
+ final String nodeHeightString = nodeElement.getAttribute("height");
+ final DiagramNodeInfo nodeInfo = new DiagramNodeInfo(
+ nodeName,
+ Integer.parseInt(nodeXString),
+ Integer.parseInt(nodeYString),
+ Integer.parseInt(nodeWidthString),
+ Integer.parseInt(nodeHeightString)
+ );
+ diagramNodeInfoList.add(nodeInfo);
+ }
+ }
+ DiagramInfo diagramInfo = new DiagramInfo(
+ Integer.parseInt(heightString),
+ Integer.parseInt(widthString),
+ diagramNodeInfoList
+ );
+
+ try
+ {
+ in.close();
+ } catch (IOException e)
+ {
+ throw new RuntimeException("Failed to close stream", e);
+ }
+
+ return diagramInfo;
+ }
+}
Added: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetGroupMembershipCommand.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetGroupMembershipCommand.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetGroupMembershipCommand.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -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.integration.jbpm3;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.command.AbstractGetObjectBaseCommand;
+import org.jbpm.command.Command;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.identity.hibernate.IdentitySession;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 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;
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetGroupMembershipCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetUsersForGroupCommand.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetUsersForGroupCommand.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetUsersForGroupCommand.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -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.integration.jbpm3;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.command.AbstractGetObjectBaseCommand;
+import org.jbpm.command.Command;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.identity.hibernate.IdentitySession;
+
+import java.util.ArrayList;
+import java.util.List;
+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;
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/GetUsersForGroupCommand.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/integration/jbpm3/JBPM3CommandDelegate.java (from rev 3073, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/JBPM3CommandDelegate.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3CommandDelegate.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3CommandDelegate.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,242 @@
+/*
+ * 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.integration.jbpm3;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.CreateException;
+
+import org.jboss.bpm.console.server.util.ServiceLocator;
+import org.jbpm.command.CancelWorkOnTaskCommand;
+import org.jbpm.command.DeleteProcessDefinitionCommand;
+import org.jbpm.command.DeployProcessCommand;
+import org.jbpm.command.GetProcessDefinitionCommand;
+import org.jbpm.command.GetProcessDefinitionsCommand;
+import org.jbpm.command.GetProcessInstanceCommand;
+import org.jbpm.command.GetProcessInstancesCommand;
+import org.jbpm.command.GetTaskInstanceCommand;
+import org.jbpm.command.GetTaskListCommand;
+import org.jbpm.command.NewProcessInstanceCommand;
+import org.jbpm.command.SignalCommand;
+import org.jbpm.command.StartWorkOnTaskCommand;
+import org.jbpm.command.TaskInstanceEndCommand;
+import org.jbpm.ejb.LocalCommandService;
+import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+/**
+ * Adopts a business interface to the command facade.<br>
+ * Depends on the CommandServiceBean (<code>java:ejb/CommandServiceBean</code>).
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class JBPM3CommandDelegate
+{
+ private LocalCommandService facade;
+ private static final String DEFAULT_JNDI_NAME = "java:ejb/CommandServiceBean";
+
+ /**
+ * Lookup with particluar JNDI name.
+ * @param jndiName
+ */
+ public JBPM3CommandDelegate(String jndiName)
+ {
+ ejbLookup(jndiName);
+ }
+
+ /**
+ * Lookup using default JNDI name.
+ *
+ * @see #DEFAULT_JNDI_NAME
+ */
+
+ public JBPM3CommandDelegate()
+ {
+ ejbLookup(DEFAULT_JNDI_NAME);
+ }
+
+ private void ejbLookup(String jndiName)
+ {
+ try
+ {
+ LocalCommandServiceHome home = (LocalCommandServiceHome)
+ ServiceLocator.getEjbLocalHome(jndiName);
+ this.facade = home.create();
+ }
+ catch (CreateException e)
+ {
+ throw new RuntimeException("Failed to create LocalCommandService", e);
+ }
+ }
+
+ public List<ProcessDefinition> getActualDefinitions()
+ {
+ List<ProcessDefinition> defs = (List<ProcessDefinition>)
+ facade.execute( new GetProcessDefinitionsCommand(false) );
+ return defs;
+ }
+
+ public ProcessDefinition getActualDefinition(String name)
+ {
+ ProcessDefinition def = (ProcessDefinition)
+ facade.execute( new GetProcessDefinitionCommand(name) );
+ return def;
+ }
+
+ public ProcessDefinition getActualDefinition(long processId)
+ {
+ List<ProcessDefinition> defs = getActualDefinitions();
+
+ ProcessDefinition match = null;
+ for(ProcessDefinition p0 : defs)
+ {
+ if(processId == p0.getId())
+ {
+ match = p0;
+ break;
+ }
+ }
+
+ if(null==match)
+ throw new IllegalArgumentException("No process definition with ID " + processId);
+
+ return match;
+ }
+
+ public void removeActualDefinition(long processId)
+ {
+ ProcessDefinition def = getActualDefinition(processId);
+ facade.execute( new DeleteProcessDefinitionCommand(processId));
+ }
+
+ public org.jbpm.graph.exe.ProcessInstance getActualInstance(long instanceId)
+ {
+ ProcessInstance instance = (ProcessInstance)
+ facade.execute( new GetProcessInstanceCommand(instanceId));
+ return instance;
+ }
+
+ public List<ProcessInstance> getActualInstances(long processId)
+ {
+ ProcessDefinition p0 = getActualDefinition(processId);
+ GetProcessInstancesCommand command = new GetProcessInstancesCommand();
+ command.setProcessId(processId);
+
+ List<ProcessInstance> instances =
+ (List<ProcessInstance>) facade.execute(command);
+
+ return instances;
+ }
+
+ public ProcessInstance startNewInstance(long processId)
+ {
+ ProcessDefinition p0 = getActualDefinition(processId);
+ ProcessInstance instance = (ProcessInstance)
+ facade.execute(new NewProcessInstanceCommand(p0.getName()));
+
+ return instance;
+ }
+
+ public ProcessDefinition deploy(byte[] data)
+ {
+ ProcessDefinition p0 = (ProcessDefinition)
+ facade.execute(
+ new DeployProcessCommand(data)
+ );
+ return p0;
+ }
+
+ public List<TaskInstance> getActualTasksForActor(String actorName)
+ {
+
+ List<String> groupNames = getGroupsForActor(actorName);
+
+ String[] actors = new String[groupNames.size()+1];
+ int i=0;
+ for(String s : groupNames)
+ {
+ actors[i] = s;
+ i++;
+ }
+
+ actors[i] = actorName; // all groups & the username
+
+ List<TaskInstance> tasks = new ArrayList<TaskInstance>();
+ GetTaskListCommand command = new GetTaskListCommand(actors);
+ tasks.addAll( (List<TaskInstance>) facade.execute(command));
+ 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
+ return (TaskInstance) facade.execute( new GetTaskInstanceCommand(taskId, true, false));
+ }
+
+ public void assignTask(long taskId, String actorId)
+ {
+ if(actorId!=null)
+ {
+ StartWorkOnTaskCommand command = new StartWorkOnTaskCommand(taskId, true);
+ command.setActorId(actorId);
+ facade.execute(command);
+ }
+ else
+ {
+ CancelWorkOnTaskCommand command = new CancelWorkOnTaskCommand(taskId);
+ facade.execute(command);
+ }
+ }
+
+ public void signalToken(long tokenId, String signalName)
+ {
+ SignalCommand command = new SignalCommand(tokenId, signalName);
+ facade.execute(command);
+ }
+
+ public void endTask(long taskId, String signalName)
+ {
+ TaskInstanceEndCommand command = new TaskInstanceEndCommand();
+ command.setTaskInstanceId(taskId);
+ command.setTransitionName(signalName);
+
+ facade.execute(command);
+ }
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3FormParser.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/JBPM3FormParser.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3FormParser.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3FormParser.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,314 @@
+/*
+ * 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.integration.jbpm3;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.console.client.model.forms.FieldDef;
+import org.jboss.bpm.console.server.util.DOMUtils;
+import org.w3c.dom.Element;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPM3FormParser
+{
+ private static final Log log = LogFactory.getLog(JBPM3FormParser.class);
+
+ private final String JSF_FACET_NAME = "facet";
+ private final static String[] JSF_TEXT_NAMES = {"outputText", "inputText"};
+ private final static String[] JSF_TEXTAREA_NAMES = { "outputTextarea","inputTextarea"};
+ private final static String[] JSF_BOOLEAN_NAMES = {"selectBooleanCheckbox"};
+ private final static String[] JSF_BUTTON_NAMES = {"saveButton", "transitionButton"};
+
+ private List<FieldDef> inputFields = new ArrayList<FieldDef>();
+ private List<InputButton> inputButtons = new ArrayList<InputButton>();
+
+ static String test = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
+ "\n" +
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\"\n" +
+ "\txmlns:ui=\"http://java.sun.com/jsf/facelets\"\n" +
+ "\txmlns:c=\"http://java.sun.com/jstl/core\"\n" +
+ "\txmlns:h=\"http://java.sun.com/jsf/html\"\n" +
+ "\txmlns:f=\"http://java.sun.com/jsf/core\"\n" +
+ "\txmlns:tf=\"http://jbpm.org/jsf/tf\" xmlns:jbpm=\"http://jbpm.org/jsf\">\n" +
+ "<ui:component>\n" +
+ "\t<jbpm:dataform>\n" +
+ "\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t<h:outputText value=\"#{taskName}\" />\n" +
+ "\t\t</f:facet>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ "\t\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t\t<h:outputText value=\"Purpose:\" />\n" +
+ "\t\t\t</f:facet>\n" +
+ "\t\t\t<h:outputText value=\"#{var['purpose']}\" />\n" +
+ "\t\t</jbpm:datacell>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ "\t\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t\t<h:outputText value=\"Description:\" />\n" +
+ "\t\t\t</f:facet>\n" +
+ "\t\t\t<h:outputText value=\"#{var['purpose']}\" />\n" +
+ "\t\t</jbpm:datacell>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ "\t\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t\t<h:outputText value=\"Self Paid\" />\n" +
+ "\t\t\t</f:facet>\n" +
+ "\t\t\t<h:selectBooleanCheckbox value=\"#{var['selfPaid']}\" disabled=\"true\" />\n" +
+ "\t\t</jbpm:datacell>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ "\t\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t\t<h:outputText value=\"Departure date\" />\n" +
+ "\t\t\t</f:facet>\n" +
+ "\t\t\t<h:outputText value=\"#{var['departureDate']}\" />\n" +
+ "\t\t</jbpm:datacell>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ "\t\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t\t<h:outputText value=\"Number of days\" />\n" +
+ "\t\t\t</f:facet>\n" +
+ "\t\t\t<h:outputText value=\"#{var['daysNum']}\" />\n" +
+ "\t\t</jbpm:datacell>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ "\t\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t\t<h:outputText value=\"Destination\" />\n" +
+ "\t\t\t</f:facet>\n" +
+ "\t\t\t<h:outputText value=\"#{var['country']}\" />\n" +
+ "\t\t</jbpm:datacell>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ " <f:facet name=\"header\">\n" +
+ " <h:outputText value=\"City:\" />\n" +
+ " </f:facet>\n" +
+ " <h:outputText value=\"#{var['city']}\" />\n" +
+ " </jbpm:datacell>\n" +
+ "\t\t<jbpm:datacell>\n" +
+ "\t\t\t<f:facet name=\"header\">\n" +
+ "\t\t\t\t<h:outputText value=\"Actions:\" />\n" +
+ "\t\t\t</f:facet>\n" +
+ "\t\t\t<tf:saveButton value=\"Save\" />\n" +
+ "\t\t\t<tf:transitionButton value=\"Approve\" transition=\"approve\" />\n" +
+ "\t\t\t<tf:transitionButton value=\"Reject\" transition=\"reject\" />\n" +
+ "\t\t</jbpm:datacell>\n" +
+ "\t</jbpm:dataform>\n" +
+ "</ui:component>\n" +
+ "</html>";
+
+ public static void main(String[] args) throws Exception
+ {
+ JBPM3FormParser p = new JBPM3FormParser();
+ p.parse( new ByteArrayInputStream(test.getBytes()));
+ p.visitResults(
+ new ParseResultVisitor()
+ {
+ public void onInputField(FieldDef field)
+ {
+ log.debug(field);
+
+ }
+
+ public void onInputButton(InputButton btn)
+ {
+ log.debug(btn);
+ }
+ }
+ );
+ }
+
+ public void parse(InputStream in) throws Exception
+ {
+ Element root = DOMUtils.parse(in);
+ Element comp = DOMUtils.getFirstChildElement(root, "component");
+ Element dataForm = DOMUtils.getFirstChildElement(comp, "dataform");
+
+ Iterator<Element> it = DOMUtils.getChildElements(dataForm, "datacell");
+ while(it.hasNext())
+ {
+ parseDatacell(it.next());
+ }
+
+ }
+
+ private String lastFieldName = null; // TODO: cleanup
+ private void parseDatacell(Element datacell)
+ {
+
+ Iterator<Element> it = DOMUtils.getChildElements(datacell);
+ while(it.hasNext())
+ {
+ Element next = it.next();
+
+ // skip facet
+ String nodeName = next.getLocalName();
+
+ if(JSF_FACET_NAME.equals(nodeName))
+ {
+ lastFieldName = parseFieldName(next);
+ continue;
+ }
+
+ for(String textName : JSF_TEXT_NAMES)
+ {
+ if(textName.equals(nodeName))
+ {
+ parseTextInputField(next);
+ continue;
+ }
+
+ }
+
+ for(String textName : JSF_TEXTAREA_NAMES)
+ {
+ if(textName.equals(nodeName))
+ {
+ parseTextAreaField(next);
+ continue;
+ }
+
+ }
+
+ for(String textName : JSF_BUTTON_NAMES)
+ {
+ if(textName.equals(nodeName))
+ {
+ parseButtonInputField(next);
+ continue;
+ }
+ }
+
+ for(String textName : JSF_BOOLEAN_NAMES)
+ {
+ if(textName.equals(nodeName))
+ {
+ parseBooleanInputField(next);
+ continue;
+ }
+ }
+ }
+
+ }
+
+ public void visitResults(ParseResultVisitor visitor)
+ {
+ for(FieldDef field : inputFields)
+ visitor.onInputField(field);
+
+ for(InputButton btn : inputButtons)
+ visitor.onInputButton(btn);
+ }
+
+ public void reset()
+ {
+ this.inputButtons.clear();
+ this.inputFields.clear();
+ }
+
+
+ private void parseTextAreaField(Element next)
+ {
+ String varName = getTrimmedVarname(next);
+ inputFields.add( new FieldDef(lastFieldName,varName, FieldDef.InputType.TEXTAREA, String.class.getName(), true));
+ }
+
+ private String getTrimmedVarname(Element next)
+ {
+ String s = DOMUtils.getAttributeValue(next, "value");
+ return trimVarName(s);
+ }
+
+ private void parseBooleanInputField(Element next)
+ {
+ String varName = getTrimmedVarname(next);
+ inputFields.add( new FieldDef(lastFieldName,varName, FieldDef.InputType.BOOL, Boolean.class.getName(), false));
+ }
+
+ private void parseButtonInputField(Element next)
+ {
+ String name = getTrimmedVarname(next);
+ String transition = DOMUtils.getAttributeValue(next, "transition");
+ inputButtons.add( new InputButton(name, transition));
+ }
+
+ private void parseTextInputField(Element next)
+ {
+ String varName = getTrimmedVarname(next);
+ inputFields.add( new FieldDef(lastFieldName, varName, FieldDef.InputType.TEXT, String.class.getName(), true));
+ }
+
+ private String parseFieldName(Element facet)
+ {
+ String fieldName = "UNKOWN_FIELDNAME";
+ if("header".equals( facet.getAttribute("name")))
+ {
+ Element outputText = DOMUtils.getFirstChildElement(facet, "outputText");
+ if(outputText!=null)
+ {
+ fieldName = DOMUtils.getAttributeValue(outputText, "value");
+ }
+ }
+
+ return fieldName;
+ }
+
+
+ public final class InputButton
+ {
+ String name;
+ String transition;
+
+ public InputButton(String name, String transition)
+ {
+ this.name = name;
+ this.transition = transition;
+ }
+
+ public boolean hasTransition()
+ {
+ return transition!=null;
+ }
+
+ public String toString()
+ {
+ return "Button{"+name+": "+transition+"}";
+ }
+ }
+
+ public interface ParseResultVisitor
+ {
+ void onInputField(FieldDef field);
+ void onInputButton(InputButton btn);
+ }
+
+ private static String trimVarName(String name)
+ {
+ String result = name;
+ if(name.startsWith("#{var['"))
+ {
+ result = name.substring(7, name.length()-3);
+ }
+
+ return result;
+ }
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementExtension.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/JBPM3ManagementExtension.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementExtension.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementExtension.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,165 @@
+/*
+ * 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.integration.jbpm3;
+
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+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.integration.JBPM3Extension;
+import org.jbpm.file.def.FileDefinition;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.util.XmlUtil;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @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)
+ {
+ ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ return p0.getFileDefinition().getBytes(PROCESSIMAGE_FILENAME);
+ }
+
+ public DiagramInfo getDiagramInfo(long processId)
+ {
+ ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ InputStream in = p0.getFileDefinition().getInputStream(GPD_XML_FILENAME);
+ return DiagramInfoParser.parse(in);
+ }
+
+ public ActiveNodeInfo getActivNodeInfo(long instanceId)
+ {
+ 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 Map<String, String> getAvailableTaskForms(long processId)
+ {
+ 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)
+ {
+ ProcessDefinition processDefinition = delegate.getActualDefinition(processId);
+ 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 void changeInstanceState(long instanceId, ProcessInstanceRef.STATE nextState)
+ {
+ ProcessInstance p0 = delegate.getActualInstance(instanceId);
+ Transform.doTransition(p0, nextState); // modifies the actual PI
+
+ // TX commit will persist changes to the actual PI
+ }
+
+ public org.jboss.bpm.console.client.model.ProcessDefinitionRef deployNewDefinition(byte[] data)
+ {
+ ProcessDefinition p0 = delegate.deploy(data);
+ return Transform.processDefinition(p0);
+ }
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementFactory.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/JBPM3ManagementFactory.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementFactory.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ManagementFactory.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -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.integration.jbpm3;
+
+import org.jboss.bpm.console.server.integration.*;
+
+/**
+ * Wraps management instances in {@link org.jboss.bpm.console.server.integration.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() );
+ }
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ProcessManagement.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/JBPM3ProcessManagement.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ProcessManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3ProcessManagement.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,105 @@
+/*
+ * 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.integration.jbpm3;
+
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.server.integration.ProcessManagement;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+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<ProcessDefinitionRef> getAllDefinitions()
+ {
+ List<ProcessDefinition> defs = delegate.getActualDefinitions();
+
+ List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>(defs.size());
+ for(ProcessDefinition p0 : defs)
+ {
+ results.add( Transform.processDefinition(p0) );
+ }
+ return results;
+ }
+
+ public ProcessDefinitionRef getDefinitionById(long processId)
+ {
+ ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ return Transform.processDefinition(p0);
+ }
+
+
+ public ProcessDefinitionRef getDefinition(String name)
+ {
+ ProcessDefinition p0 = delegate.getActualDefinition(name);
+ return Transform.processDefinition(p0);
+ }
+
+ public List<ProcessDefinitionRef> removeDefinition(long processId)
+ {
+ delegate.removeActualDefinition(processId);
+ return getAllDefinitions();
+ }
+
+
+ public ProcessInstanceRef newInstance(long processId)
+ {
+ ProcessInstance instance = delegate.startNewInstance(processId);
+ return Transform.processInstance(instance);
+ }
+
+ public List<ProcessInstanceRef> getInstancesByDefinitionId(long processId)
+ {
+ List<ProcessInstance> instances = delegate.getActualInstances(processId);
+ List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>(instances.size());
+ for(org.jbpm.graph.exe.ProcessInstance i0 : instances)
+ {
+ results.add( Transform.processInstance(i0) );
+ }
+ return results;
+ }
+
+ public ProcessInstanceRef getInstanceById(long instanceId)
+ {
+ ProcessInstance instance = delegate.getActualInstance(instanceId);
+ return Transform.processInstance(instance);
+ }
+
+ public void signalToken(long tokenId, String signal)
+ {
+ delegate.signalToken(tokenId, signal);
+ }
+
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3TaskManagement.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/JBPM3TaskManagement.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3TaskManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3TaskManagement.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,78 @@
+/*
+ * 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.integration.jbpm3;
+
+import org.jboss.bpm.console.client.model.TaskRef;
+import org.jboss.bpm.console.server.integration.TaskManagement;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+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<TaskRef> getTasksByActor(String actorName)
+ {
+
+ List<TaskInstance> actualTasks =
+ delegate.getActualTasksForActor(actorName);
+
+ List<TaskRef> taskRefs = new ArrayList<TaskRef>();
+ for(TaskInstance t0 : actualTasks)
+ {
+ taskRefs.add( Transform.taskInstance(t0));
+ }
+
+ return taskRefs;
+ }
+
+ public TaskRef getTaskById(long taskId)
+ {
+ TaskInstance t0 = delegate.getTaskById(taskId);
+ TaskRef 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/integration/jbpm3/JBPM3UserManagement.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/JBPM3UserManagement.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3UserManagement.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3UserManagement.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -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.integration.jbpm3;
+
+import org.jboss.bpm.console.server.integration.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);
+ }
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/Transform.java (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/Transform.java)
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/Transform.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/Transform.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,141 @@
+/*
+ * 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.integration.jbpm3;
+
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.model.TaskRef;
+import org.jboss.bpm.console.client.model.jbpm3.TokenReference;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.exe.Token;
+import org.jbpm.taskmgmt.exe.PooledActor;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class Transform
+{
+ public static ProcessDefinitionRef processDefinition(org.jbpm.graph.def.ProcessDefinition p0)
+ {
+ return new ProcessDefinitionRef(p0.getId(), p0.getName(), String.valueOf(p0.getVersion()));
+ }
+
+ public static ProcessInstanceRef processInstance(org.jbpm.graph.exe.ProcessInstance i0)
+ {
+ Date start = i0.getStart();
+ Date end = i0.getEnd();
+ boolean suspended = i0.isSuspended();
+ long processId = i0.getProcessDefinition().getId();
+ long instanceId = i0.getId();
+ ProcessInstanceRef processInstance = new ProcessInstanceRef(instanceId, processId, start, end, suspended);
+
+ // token
+ Token t0 = i0.getRootToken();
+ processInstance.setRootToken(Transform.tokenReference(t0));
+ return processInstance;
+ }
+
+ private static TokenReference tokenReference(Token t0)
+ {
+ TokenReference token = new TokenReference(t0.getId(), t0.getName(), t0.getNode().getName());
+
+ if(t0.hasActiveChildren() || t0.isTerminatedImplicitly())
+ token.setCanBeSignaled(false);
+
+ Map children = t0.getChildren();
+ if(children!=null)
+ {
+ for(Object o : children.values())
+ {
+ Token t1 = (Token)o;
+ token.getChildren().add( Transform.tokenReference(t1) );
+ }
+ }
+
+ // signals
+ for(Object tr0 : t0.getNode().getLeavingTransitionsList())
+ {
+ Transition transition = (Transition)tr0;
+ token.getAvailableSignals().add(transition.getName());
+ }
+
+ return token;
+ }
+
+ public static void doTransition(org.jbpm.graph.exe.ProcessInstance p0, ProcessInstanceRef.STATE nextState)
+ {
+ ProcessInstanceRef instance = Transform.processInstance(p0);
+ instance.setState(nextState); // has lifecycle build in, hence the extra round
+
+ switch(instance.getState())
+ {
+ case ENDED:
+ p0.setEnd(instance.getEndDate());
+ p0.end();
+ break;
+ case SUSPENDED:
+ p0.suspend();
+ break;
+ case RUNNING:
+ if(p0.isSuspended())
+ p0.resume();
+ }
+
+ }
+
+ public static TaskRef taskInstance(org.jbpm.taskmgmt.exe.TaskInstance t0)
+ {
+ TaskRef taskRef = new TaskRef(
+ t0.getId(),
+ t0.getToken().getId(),
+ t0.getProcessInstance().getId(),
+ t0.getProcessInstance().getProcessDefinition().getId(),
+ t0.getName(), t0.getActorId(),
+ t0.isBlocking(), t0.isSignalling()
+ );
+
+ List<Transition> transitionList = (List<Transition>)
+ t0.getToken().getNode().getLeavingTransitionsList();
+
+ Set<PooledActor> pooledActors = (Set<PooledActor>)t0.getPooledActors();
+ for(PooledActor p : pooledActors)
+ {
+ taskRef.addPooledActor(p.getActorId());
+ }
+
+ for(Transition trs0 : transitionList)
+ {
+ taskRef.getTransitionNames().add(
+ trs0.getName()
+ );
+ }
+
+ return taskRef;
+ }
+
+
+}
Copied: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/cmd (from rev 3072, projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/cmd)
Deleted: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/cmd/GetGroupMembershipCommand.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/cmd/GetGroupMembershipCommand.java 2008-11-25 10:19:51 UTC (rev 3072)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/cmd/GetGroupMembershipCommand.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -1,72 +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.integration.internal.cmd;
-
-import org.jbpm.JbpmContext;
-import org.jbpm.command.AbstractGetObjectBaseCommand;
-import org.jbpm.command.Command;
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-import org.jbpm.identity.hibernate.IdentitySession;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * 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/integration/jbpm3/cmd/GetUsersForGroupCommand.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/internal/cmd/GetUsersForGroupCommand.java 2008-11-25 10:19:51 UTC (rev 3072)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/cmd/GetUsersForGroupCommand.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -1,71 +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.integration.internal.cmd;
-
-import org.jbpm.JbpmContext;
-import org.jbpm.command.AbstractGetObjectBaseCommand;
-import org.jbpm.command.Command;
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-import org.jbpm.identity.hibernate.IdentitySession;
-
-import java.util.ArrayList;
-import java.util.List;
-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;
- }
-}
Added: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ProcessManagementImpl.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ProcessManagementImpl.java (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ProcessManagementImpl.java 2008-11-25 11:05:53 UTC (rev 3074)
@@ -0,0 +1,78 @@
+/*
+ * 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.integration.spec;
+
+import java.util.List;
+
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.server.integration.ProcessManagement;
+import org.jbpm.api.NotImplementedException;
+
+/**
+ * An implementation that delegates to the jBPM API
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 25-Nov-2008
+ */
+public class ProcessManagementImpl implements ProcessManagement
+{
+ public List<ProcessDefinitionRef> getAllDefinitions()
+ {
+ throw new NotImplementedException();
+ }
+
+ public ProcessDefinitionRef getDefinitionById(long processId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ProcessDefinitionRef getDefinition(String name)
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<ProcessDefinitionRef> removeDefinition(long processId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ProcessInstanceRef newInstance(long processId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<ProcessInstanceRef> getInstancesByDefinitionId(long processId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ProcessInstanceRef getInstanceById(long instanceId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void signalToken(long tokenId, String signal)
+ {
+ throw new NotImplementedException();
+ }
+}
Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ProcessManagementImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jbpm-commits
mailing list