Workflow checkpoint:

- BPM Engine Registry & Plug-in SPIs
- First JBoss JBPM based Implementation of SPIs
- Workflow Service Implementation
- Tests

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3436 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2006-07-28 22:58:02 +00:00
parent 0c35c285bd
commit 25123a4504
22 changed files with 2556 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.cmr.view.ExporterService;
import org.alfresco.service.cmr.view.ImporterService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -81,6 +82,7 @@ public interface ServiceRegistry
static final QName TEMPLATE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TemplateService");
static final QName FILE_FOLDER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FileFolderService");
static final QName SCRIPT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ScriptService");
static final QName WORKFLOW_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WorkflowService");
/**
* Get the list of services provided by the Repository
@@ -254,4 +256,10 @@ public interface ServiceRegistry
*/
@NotAuditable
ScriptService getScriptService();
/**
* @return the workflow service (or null if one is not provided)
*/
@NotAuditable
WorkflowService getWorkflowService();
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
/**
* Workflow Definition Data Object
*
* @author davidc
*/
public class WorkflowDefinition
{
/** Workflow Definition unique id */
public String id;
/** Workflow Definition name */
public String name;
/** Task Definition for Workflow Start Task (Optional) */
public WorkflowTaskDefinition startTaskDefinition;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
return "WorkflowDefinition[id=" + id + ",name=" + name + ",startTask=" + startTaskDefinition.toString() + "]";
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Base Exception of Workflow Exceptions.
*
* @author David Caruana
*/
public class WorkflowException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = -7338963365877285084L;
public WorkflowException(String msgId)
{
super(msgId);
}
public WorkflowException(String msgId, Throwable cause)
{
super(msgId, cause);
}
public WorkflowException(String msgId, Object ... args)
{
super(msgId, args);
}
public WorkflowException(String msgId, Throwable cause, Object ... args)
{
super(msgId, args, cause);
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
/**
* Workflow Instance Data Object
*
* Represents an "in-flight" workflow.
*
* @author davidc
*/
public class WorkflowInstance
{
/** Workflow Instance unique id */
public String id;
/** Is this Workflow instance still "in-flight" or has it completed? */
public boolean active;
/** Workflow Definition */
public WorkflowDefinition definition;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
return "WorkflowInstance[id=" + id + ",active=" + active + ",def=" + definition.toString() + "]";
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
/**
* Workflow Node Data Object
*
* Represents a Node within the Workflow Definition.
*
* @author davidc
*/
public class WorkflowNode
{
/** Name of the Workflow Node */
public String name;
/** Type of the Workflow Node (typically this is BPM engine specific - informational only */
public String type;
/** Does this Workflow Node represent human interaction? */
public boolean isTaskNode;
/** The transitions leaving this node (or null, if none) */
public String[] transitions;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
String transitionsArray = "{";
for (int i = 0; i < transitions.length; i++)
{
transitionsArray += ((i == 0) ? "" : ",") + "'" + transitions[i] + "'";
}
transitionsArray += "}";
return "WorkflowNode[name=" + name + ",type=" + type + ",transitions=" + transitionsArray + "]";
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
/**
* Workflow Path Data Object
*
* Represents a path within an "in-flight" workflow instance.
*
* Simple workflows consists of a single "root" path. Multiple paths occur when a workflow
* instance branches, therefore more than one concurrent path is taken.
*
* @author davidc
*/
public class WorkflowPath
{
/** Unique id of Workflow Path */
public String id;
/** Workflow Instance this path is part of */
public WorkflowInstance instance;
/** The Workflow Node the path is at */
public WorkflowNode node;
/** Is the path still active? */
public boolean active;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
return "WorkflowPath[id=" + id + ",instance=" + instance.toString() + ",active=" + active + ",node=" + node.toString()+ "]";
}
}

View File

@@ -0,0 +1,194 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* Workflow Service.
*
* Client facing API for interacting with Alfresco Workflows and Tasks.
*
* @author davidc
*/
public interface WorkflowService
{
//
// Workflow Definition Management
//
/**
* Deploy a Workflow Definition to the Alfresco Repository
*
* Note: The specified content object must be of type bpm:workflowdefinition.
* This type describes for which BPM engine the definition is appropriate.
*
* @param workflowDefinition the content object containing the definition
* @return workflow definition
*/
public WorkflowDefinition deployDefinition(NodeRef workflowDefinition);
/**
* Undeploy an exisiting Workflow Definition
*
* TODO: Determine behaviour when "in-flight" workflow instances exist
*
* @param workflowDefinitionId the id of the definition to undeploy
*/
public void undeployDefinition(String workflowDefinitionId);
/**
* Gets all deployed Workflow Definitions
*
* @return the deployed workflow definitions
*/
public List<WorkflowDefinition> getDefinitions();
/**
* Gets a Workflow Definition by unique Id
*
* @param workflowDefinitionId the workflow definition id
* @return the deployed workflow definition
*/
public WorkflowDefinition getDefinitionById(String workflowDefinitionId);
//
// Workflow Instance Management
//
/**
* Start a Workflow Instance
*
* @param workflowDefinitionId the workflow definition id
* @param parameters the initial set of parameters used to populate the "Start Task" properties
* @return the initial workflow path
*/
public WorkflowPath startWorkflow(String workflowDefinitionId, Map<QName, Serializable> parameters);
/**
* Start a Workflow Instance from an existing "Start Task" template node held in the
* Repository. The node must be of the Type as described in the Workflow Definition.
*
* @param templateDefinition the node representing the Start Task properties
* @return the initial workflow path
*/
public WorkflowPath startWorkflowFromTemplate(NodeRef templateDefinition);
/**
* Gets all "in-flight" workflow instances of the specified Workflow Definition
*
* @param workflowDefinitionId the workflow definition id
* @return the list of "in-fligth" workflow instances
*/
public List<WorkflowInstance> getActiveWorkflows(String workflowDefinitionId);
/**
* Gets all Paths for the specified Workflow instance
*
* @param workflowId workflow instance id
* @return the list of workflow paths
*/
public List<WorkflowPath> getWorkflowPaths(String workflowId);
/**
* Cancel an "in-fligth" Workflow instance
*
* @param workflowId the workflow instance to cancel
* @return an updated representation of the workflow instance
*/
public WorkflowInstance cancelWorkflow(String workflowId);
/**
* Signal the transition from one Workflow Node to another
*
* @param pathId the workflow path to signal on
* @param transition the transition to follow (or null, for the default transition)
* @return the updated workflow path
*/
public WorkflowPath signal(String pathId, String transition);
/**
* Gets all Tasks associated with the specified path
*
* @param pathId the path id
* @return the list of associated tasks
*/
public List<WorkflowTask> getTasksForWorkflowPath(String pathId);
//
// Task Management
//
/**
* Gets a Task by unique Id
*
* @param taskId the task id
* @return the task
*/
public WorkflowTask getTaskById(String taskId);
/**
* Gets all tasks assigned to the specified authority
*
* @param authority the authority
* @param state filter by specified workflow task state
* @return the list of assigned tasks
*/
public List<WorkflowTask> getAssignedTasks(String authority, WorkflowTaskState state);
/**
* Gets the pooled tasks available to the specified authority
*
* @param authority the authority
* @return the list of pooled tasks
*/
public List<WorkflowTask> getPooledTasks(String authority);
/**
* Update the Properties and Associations of a Task
*
* @param taskId the task id to update
* @param properties the map of properties to set on the task (or null, if none to set)
* @param add the map of items to associate with the task (or null, if none to add)
* @param remove the map of items to dis-associate with the task (or null, if none to remove)
* @return the update task
*/
public WorkflowTask updateTask(String taskId, Map<QName, Serializable> properties, Map<QName, List<NodeRef>> add, Map<QName, List<NodeRef>> remove);
/**
* End the Task (i.e. complete the task)
*
* @param taskId the task id to end
* @param transition the task transition to take on completion (or null, for the default transition)
* @return the updated task
*/
public WorkflowTask endTask(String taskId, String transition);
// todo: workflow package apis
// createPackage
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* Workflow Task Data Object
*
* Represents a human-oriented task within an "in-fligth" workflow instance
*
* @author davidc
*/
public class WorkflowTask
{
/** Unique id of Task */
public String id;
/** Name of Task */
public String name;
/** Task State */
public WorkflowTaskState state;
/** Workflow path this Task is associated with */
public WorkflowPath path;
/** Task Definition */
public WorkflowTaskDefinition definition;
/** Task Properties as described by Task Definition */
public Map<QName, Serializable> properties;
/** Task Associations as described by Task Definition */
public Map<QName, List<NodeRef>> associations;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
return "WorkflowTask[id=" + id + ",name=" + name + ",state=" + state + ",def=" + definition + ",path=" + path.toString() + "]";
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
/**
* Workflow Task Definition Data Object.
*
* Represents meta-data for a Workflow Task. The meta-data is described in terms
* of the Alfresco Data Dictionary.
*
* @author davidc
*/
public class WorkflowTaskDefinition
{
/** Unique id of Workflow Task Definition */
public String id;
// TODO: Convert to TaskDefinition (derived from TypeDefinition)
/** Task Metadata */
public TypeDefinition metadata;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
return "WorkflowTaskDefinition[id=" + id + ",metadata=" + metadata + "]";
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.workflow;
/**
* Workflow Task State
*
* Represents the high-level state of Workflow Task (in relation to "in-flight"
* workflow instance).
*
* A user-defined task state may be represented as Task Property (and described
* by the Alfresco Data Dictionary).
*
* @author davidc
*/
public enum WorkflowTaskState
{
IN_PROGRESS,
COMPLETED;
}