[jbpm-commits] JBoss JBPM SVN: r3143 - in projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration: spec and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Nov 28 06:05:30 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-11-28 06:05:29 -0500 (Fri, 28 Nov 2008)
New Revision: 3143

Added:
   projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/TaskManagementImpl.java
   projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/UserManagementImpl.java
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/spec/ManagementFactoryImpl.java
   projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ProcessManagementImpl.java
Log:
Add task & identity service

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-28 11:05:17 UTC (rev 3142)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/ManagementFactory.java	2008-11-28 11:05:29 UTC (rev 3143)
@@ -23,7 +23,6 @@
 
 // $Id: $
 
-import org.jboss.bpm.console.server.integration.jbpm3.JBPM3ManagementFactory;
 import org.jboss.bpm.console.server.integration.spec.ManagementFactoryImpl;
 
 /**
@@ -42,9 +41,9 @@
   
   public abstract ProcessManagement createProcessManagement();
 
-  public abstract ExtensionManagement createExtensionManagement();
-
   public abstract TaskManagement createTaskManagement();
 
   public abstract UserManagement createUserManagement();
+  
+  public abstract ExtensionManagement createExtensionManagement();
 }

Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ManagementFactoryImpl.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ManagementFactoryImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ManagementFactoryImpl.java	2008-11-28 11:05:29 UTC (rev 3143)
@@ -28,32 +28,29 @@
 import org.jboss.bpm.console.server.integration.TaskManagement;
 import org.jboss.bpm.console.server.integration.UserManagement;
 import org.jboss.bpm.console.server.integration.jbpm3.JBPM3ManagementExtension;
-import org.jboss.bpm.console.server.integration.jbpm3.JBPM3TaskManagement;
-import org.jboss.bpm.console.server.integration.jbpm3.JBPM3UserManagement;
 
 /**
- * Wraps management instances in {@link InvocationProxy}
  * @author Thomas.Diesler at jboss.com
  */
 public class ManagementFactoryImpl extends ManagementFactory
 {
    public ProcessManagement createProcessManagement()
    {
-      return (ProcessManagement) InvocationProxy.newInstance(new ProcessManagementImpl());
+      return new ProcessManagementImpl();
    }
 
-   public ExtensionManagement createExtensionManagement()
+   public TaskManagement createTaskManagement()
    {
-      return (ExtensionManagement) InvocationProxy.newInstance( new JBPM3ManagementExtension() );
+      return new TaskManagementImpl();
    }
 
-   public TaskManagement createTaskManagement()
+   public UserManagement createUserManagement()
    {
-      return (TaskManagement) InvocationProxy.newInstance( new JBPM3TaskManagement() );
+      return new UserManagementImpl();
    }
 
-   public UserManagement createUserManagement()
+   public ExtensionManagement createExtensionManagement()
    {
-      return (UserManagement) InvocationProxy.newInstance( new JBPM3UserManagement() );
+      return (ExtensionManagement) InvocationProxy.newInstance( new JBPM3ManagementExtension() );
    }
 }

Modified: 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	2008-11-28 11:05:17 UTC (rev 3142)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/ProcessManagementImpl.java	2008-11-28 11:05:29 UTC (rev 3143)
@@ -49,7 +49,7 @@
 import org.jboss.bpm.console.server.integration.ProcessManagement;
 
 /**
- * An implementation that delegates to the jBPM API
+ * An implementation that delegates to a BPM Spec.
  * 
  * @author Thomas.Diesler at jboss.com
  * @since 25-Nov-2008
@@ -182,7 +182,7 @@
       Process proc = procService.getProcess(procID);
       for (Token aux : proc.getTokens())
       {
-        Long auxId = apaptKey(aux.getKey());
+        Long auxId = adaptKey(aux.getKey());
         if (auxId == tokenId)
         {
           token = aux;
@@ -217,7 +217,7 @@
     while (it.hasNext())
     {
       ObjectName auxKey = it.next();
-      if (procDefID == apaptKey(auxKey))
+      if (procDefID == adaptKey(auxKey))
       {
         procDef = pdService.getProcessDefinition(auxKey);
         break;
@@ -229,7 +229,7 @@
   private ProcessDefinitionRef adaptProcessDefinition(ProcessDefinition procDef)
   {
     ObjectName procDefKey = procDef.getKey();
-    Long procDefID = apaptKey(procDefKey);
+    Long procDefID = adaptKey(procDefKey);
     return new ProcessDefinitionRef(procDefID, procDef.getName(), procDef.getVersion());
   }
 
@@ -248,7 +248,7 @@
     while (it.hasNext())
     {
       ObjectName auxKey = it.next();
-      if (procID == apaptKey(auxKey))
+      if (procID == adaptKey(auxKey))
       {
         proc = procService.getProcess(auxKey);
         break;
@@ -259,8 +259,8 @@
 
   private ProcessInstanceRef adaptProcess(Process proc)
   {
-    Long procDefID = apaptKey(proc.getProcessDefinition().getKey());
-    Long procID = apaptKey(proc.getKey());
+    Long procDefID = adaptKey(proc.getProcessDefinition().getKey());
+    Long procID = adaptKey(proc.getKey());
 
     // The BPM Spec does not (yet) have the notion of a suspended Process
     boolean suspended = false;
@@ -275,7 +275,7 @@
 
   private TokenReference adaptToken(Token token)
   {
-    Long tokenId = apaptKey(token.getKey());
+    Long tokenId = adaptKey(token.getKey());
     token.getKey();
 
     Node currNode = token.getCurrentNode();
@@ -309,7 +309,7 @@
     return tokenRef;
   }
 
-  private Long apaptKey(ObjectName key)
+  private Long adaptKey(ObjectName key)
   {
     String id = key.getKeyProperty("id");
     if (id == null)

Added: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/TaskManagementImpl.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/TaskManagementImpl.java	                        (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/TaskManagementImpl.java	2008-11-28 11:05:29 UTC (rev 3143)
@@ -0,0 +1,162 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.api.client.Configuration;
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.model.Node;
+import org.jboss.bpm.api.model.Process;
+import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.model.SingleOutFlowSupport;
+import org.jboss.bpm.api.model.builder.ObjectNameFactory;
+import org.jboss.bpm.api.runtime.Token;
+import org.jboss.bpm.api.service.ExecutionService;
+import org.jboss.bpm.api.service.TaskService;
+import org.jboss.bpm.api.task.Task;
+import org.jboss.bpm.console.client.model.TaskRef;
+import org.jboss.bpm.console.server.integration.TaskManagement;
+
+/**
+ * An implementation that delegates to a BPM Spec.
+ * 
+ * https://jira.jboss.org/jira/browse/JBPM-1892
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 28-Nov-2008
+ */
+public class TaskManagementImpl implements TaskManagement
+{
+  private static final Log log = LogFactory.getLog(TaskManagementImpl.class);
+
+  public TaskRef getTaskById(long taskId)
+  {
+    log.info("getTaskById: " + taskId);
+    
+    ObjectName taskKey = getTaskKey(taskId);
+    TaskService taskService = getTaskService();
+    Task task = taskService.getTask(taskKey);
+    
+    return adaptTask(task);
+  }
+
+  public List<TaskRef> getTasksByActor(String actor)
+  {
+    log.info("getTasksByActor: " + actor);
+    
+    List<TaskRef> taskRefs = new ArrayList<TaskRef>();
+    TaskService taskService = getTaskService();
+    for (Task task : taskService.getTasksByActor(actor))
+    {
+      log.info(task);
+      taskRefs.add(adaptTask(task));
+    }
+    return taskRefs;
+  }
+
+  public void closeTask(long taskId, String signalName)
+  {
+    log.info("closeTask: " + taskId + "," + signalName);
+    
+    ObjectName taskKey = getTaskKey(taskId);
+    TaskService taskService = getTaskService();
+    taskService.closeTask(taskKey, signalName);
+  }
+
+  public void reassignTask(long taskId, String actor)
+  {
+    log.info("reassignTask: " + taskId + "," + actor);
+    
+    ObjectName taskKey = getTaskKey(taskId);
+    TaskService taskService = getTaskService();
+    taskService.reassignTask(taskKey, actor);
+  }
+
+  private TaskRef adaptTask(Task task)
+  {
+    Long taskId = adaptKey(task.getKey());
+    
+    ObjectName tokenKey = task.getCorrelationKey();
+    Token token = getExecutionService().getToken(tokenKey);
+    Long tokenId = adaptKey(tokenKey);
+    
+    Process proc = token.getProcess();
+    Long procId = adaptKey(proc.getKey());
+    
+    ProcessDefinition procDef = proc.getProcessDefinition();
+    Long procDefId = adaptKey(procDef.getKey());
+    
+    TaskRef taskRef = new TaskRef(taskId, tokenId, procId, procDefId, task.getName(), task.getActor(), task.isBlocking(), task.isSignalling());
+
+    for (String pa : task.getPooledActors())
+    {
+      taskRef.addPooledActor(pa);
+    }
+
+    Node currentNode = token.getCurrentNode();
+    if (currentNode instanceof SingleOutFlowSupport)
+    {
+      SingleOutFlowSupport sofs = (SingleOutFlowSupport)currentNode;
+      String targetName = sofs.getOutFlow().getName();
+      if (targetName == null)
+        targetName = sofs.getOutFlow().getTargetRef();
+      
+      taskRef.getTransitionNames().add(targetName);
+    }
+
+    return taskRef;
+  }
+
+  private Long adaptKey(ObjectName key)
+  {
+    String id = key.getKeyProperty("id");
+    if (id == null)
+      throw new IllegalStateException("Cannot obtain id property from: " + key);
+
+    return new Long(id);
+  }
+  
+  private ObjectName getTaskKey(long taskId)
+  {
+    return ObjectNameFactory.create("Task:id= " + taskId);
+  }
+
+  private TaskService getTaskService()
+  {
+    ProcessEngine engine = Configuration.getProcessEngine();
+    TaskService taskService = engine.getService(TaskService.class);
+    return taskService;
+  }
+  
+  private ExecutionService getExecutionService()
+  {
+    ProcessEngine engine = Configuration.getProcessEngine();
+    ExecutionService exService = engine.getService(ExecutionService.class);
+    return exService;
+  }
+}


Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/TaskManagementImpl.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/spec/UserManagementImpl.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/UserManagementImpl.java	                        (rev 0)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/UserManagementImpl.java	2008-11-28 11:05:29 UTC (rev 3143)
@@ -0,0 +1,73 @@
+/*
+ * 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.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.api.client.Configuration;
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.service.IdentityService;
+import org.jboss.bpm.console.server.integration.UserManagement;
+
+/**
+ * An implementation that delegates to a BPM Spec.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 28-Nov-2008
+ */
+public class UserManagementImpl implements UserManagement
+{
+  private static final Log log = LogFactory.getLog(UserManagementImpl.class);
+  
+  public List<String> getGroupsForActor(String actor)
+  {
+    log.info("getGroupsForActor: " + actor);
+    
+    IdentityService identService = getIdentityService();
+    List<String> groups = identService.getGroupsByActor(actor);
+
+    log.info(groups);
+    
+    return groups;
+  }
+
+  public List<String> getActorsForGroup(String group)
+  {
+    log.info("getActorsForGroup: " + group);
+    
+    IdentityService identService = getIdentityService();
+    List<String> actors = identService.getActorsByGroup(group);
+    
+    log.info(actors);
+    
+    return actors;
+  }
+
+  private IdentityService getIdentityService()
+  {
+    ProcessEngine engine = Configuration.getProcessEngine();
+    IdentityService identService = engine.getService(IdentityService.class);
+    return identService;
+  }
+}


Property changes on: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/spec/UserManagementImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list