[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/workflow - __init__.py:1.1 stateful.py:1.1 wfmc.py:1.1

Ulrich Eck ueck@net-labs.de
Sat, 1 Feb 2003 14:17:41 -0500


Update of /cvs-repository/Zope3/src/zope/app/interfaces/workflow
In directory cvs.zope.org:/tmp/cvs-serv17845/workflow

Added Files:
	__init__.py stateful.py wfmc.py 
Log Message:
Rotterdam Workflow-Code Migration:

First Draft of new Interface Structure:

workflow/__init__.py: Generic Interfaces for all Workflow-Implementations
                      and WorkflowService
workflow/stateful.py: Interfaces for Stateful Workflow (Draft)
workflow/wfmc.py    : Interfaces for Activity-Based (WfMC) Workflow (Draft)

the implementation will be developed outside of Zope3 CVS-HEAD till we
reach a first usable state. the workflow-package will temporarily live
in Zope-CVS Packages3/workflow.


=== Added File Zope3/src/zope/app/interfaces/workflow/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
    Interfaces for workflow service, definition and instance.
"""

from zope.interface import Interface
from zope.interface import Attribute
from zope.app.interfaces.services.configuration \
     import INamedComponentConfiguration




class IWorkflowService(Interface):
    """Workflow service.

    A workflow service manages the process definitions.
    """

    def getProcessDefinitionNames():
        """Return the definition names.

        Returns a sequence of names.
        """

    def getProcessDefinition(name):
        """Return the IProcessDefinition for the name.
        """

    def createProcessInstance(definition_name):
        """Create a process instance from a process definition.
        """






class IProcessDefinition(Interface):
    """Interface for workflow process definition.
    """

    name = Attribute("""The name of the ProcessDefinition""")


    def createProcessInstance():
        """Create a new process instance for this process definition.

        Returns an IProcessInstance.
        """



class IProcessDefinitionConfiguration(INamedComponentConfiguration):
    """Configuration for a workflow process definition.
    """





class IProcessInstance(Interface):
    """Workflow process instance.

    Represents the instance of a process defined by a ProcessDefinition.
    """

    status = Attribute("The state in which the workitem is.")

    processDefinition = Attribute("The process definition.")



class IProcessInstanceContainer(Interface):
    """Workflow process instance container.
    """

    def addProcessInstance(name, pi):
        """Add the process instance, associated to name.
        """

    def getProcessInstance(name):
        """Get the process instance associated to the given name.
        """

    def getProcessInstanceNames():
        """Get the names associated to all process instances.
        """

    def delProcessInstance(name):
        """Remove the process instance associated to name.
        """


class IProcessInstanceContainerAdaptable(Interface):
    """Marker interface for components that can be
       adapted to a process instance container.
    """





class IProcessInstanceControl(Interface):
    """Interface to interact with a process instance.
    """

    def start():
        """Start a process instance.
        """

    def finish():
        """Finish a process instance.
        """




class IWorklistHandler(Interface):
    """Base interface for Workflow Worklist Handler.
    """

    def getWorkitems():
        """Return a sequence of workitem.
        """





class IProcessDefinitionImportExport(Interface):
    """ProcessDefinition Import/Export.
    """

    def importProcessDefinition(process_definition):
        """Import a Process Definition
        """

    def exportProcessDefinition(pd_id):
        """Export a Process Definition
        """





=== Added File Zope3/src/zope/app/interfaces/workflow/stateful.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

"""Interfaces for stateful workflow process definition.

$Id: stateful.py,v 1.1 2003/02/01 19:17:39 jack-e Exp $
"""
from zope.interface import Interface, Attribute
from zope.app.interfaces.workflow import IProcessDefinition
from zope.app.interfaces.workflow import IProcessInstance

class IStatefulProcessDefinition(IProcessDefinition):
    """Interface for stateful workflow process definition.
    """

    def addState(name, state):
        """Add a IState to the process definition.
        """

    def getState(name):
        """Get the named state.
        """

    def removeState(name):
        """Remove a state from the process definition

        Raises ValueError exception if trying to delete the initial state.
        """

    def getStateNames():
        """Get the state names.
        """

    def getInitialStateName():
        """Get the name of the initial state.
        """

    def addTransition(name, transition):
        """Add a ITransition to the process definition.
        """

    def getTransition(name):
        """Get the named transition.
        """

    def removeTransition(name):
        """Remove a transition from the process definition.
        """

    def getTransitionNames():
        """Get the transition names.
        """




class IState(Interface):
    """Interface for state of a stateful workflow process definition.
    """


class ITransition(Interface):
    """Stateful workflow transition.
    """

    destinationState = Attribute("Name of the destination state.")

    condition = Attribute("""The condition that is evaluated to decide if \
                             the condition is fired or not.""")


class IBasicTransition(ITransition):
    """Basic stateful workflow transition.
    """

    sourceState = Attribute("Name of the source state.")




class IStatefulProcessInstance(IProcessInstance):
    """Workflow process instance.

    Represents the instance of a process defined by a
    StatefulProcessDefinition.
    """

    def getOutgoingTransitions():
        """Get the outgoing transitions.
        """

    def fireTransition(id):
        """Fire a outgoing transitions.
        """



class IContentWorkflowsUtility(Interface):
    """A Content Workflows Utility.

    it associates content objects with some workflow process definitions.
    """

    def subscribe():
        """Subscribe to the prevailing object hub service.
        """

    def unsubscribe():
        """Unsubscribe from the object hub service.
        """

    def isSubscribed():
        """Return whether we are currently subscribed.
        """

    def getProcessDefinitionNames():
        """Get the process definition names.
        """

    def setProcessDefinitionNames(names):
        """Set the process definition names.
        """


=== Added File Zope3/src/zope/app/interfaces/workflow/wfmc.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

"""Interfaces for WfMC workflow process definition.

Status: Draft

$Id: wfmc.py,v 1.1 2003/02/01 19:17:39 jack-e Exp $
"""
from zope.interface import Interface, Attribute

from zope.app.interfaces.workflow import IProcessDefinition
from zope.app.interfaces.workflow import IProcessInstance

from zope.app.interfaces.container import IContainer


# ToDo:
# - Specify all Attributes as SchemaFields where possible
# - Define necessary methods for Interfaces


class IWfMCProcessDefinition(IProcessDefinition):
    """WfMC Workflow process definition.
    """

    # will we have packages ??
    # package = Attribute("ref to package")

    processDefinitionHeader = Attribute("ref to pd header")

    redefinableHeader = Attribute("ref to refinable header")

    formalParameters = Attribute("parameters that are interchanged e.g. subflow")

    relevantData = Attribute("wfr data definition")

    participants = Attribute("colletion of participants")

    applications = Attribute("collection of applictations")

    startActivity = Attribute("ref to start activity")

    endActivity = Attribute("ref to end activity")

    activities = Attribute("list activities contained by PD")

    transitions = Attribute("list transitions contained by PD")



class IWfMCProcessDefinitionHeader(Interface):
    """WfMC Workflow process definition header.
    """

    created = Attribute("date of creation")
    
    description = Attribute("description of package")
    
    validFrom = Attribute("date the PD is valid from")
    
    validTo = Attribute("date the PD is valid to")
    
    limit = Attribute("limit for timemanagement in units of DurationUnit")
    
    priority = Attribute("priority of PD")
    
    durationUnit = Attribute("Duration Unit")
    
    workingTime = Attribute("amount of time, performer of activity needs to perform task")
    
    waitingTime = Attribute("amount of time, needed to prepare performance of task")
    
    duration = Attribute("duration in units")
    
    timeEstimation = Attribute("estimated time for the process")



class IWfMCProcessDefinitionElement(Interface):
    """WfMC process definition Element."""

    # components usually don't know their id within a container
    # id = Attribute("id of ProcessDefinitionElement")

    # we have to decide how to handle the Extended Attributes
    extendedAttributes = Attribute("list of extended Attributes")




## FormalParameter Declaration

class IWfMCFormalParameter(IContainer):
    """WfMC Formal Parameters Container.
    """

class IWfMCFormalParameter(IWfMCProcessDefinitionElement):
    """WfMC Formal Parameter.
    """

    mode = Attribute("mode: in/out/inout")
    
    index = Attribute("index of par")
    
    dataType = Attribute("data type of Parameter")
    
    description = Attribute("the Parameter Description")


## RelevantData Declaration

class IWfMCRelevantDataContainer(IContainer):
    """WfMC Relevant Data Container.
    """

class IWfMCRelevantData(IWfMCProcessDefinitionElement):
    """WfMC Relevant Data.
    """

    name = Attribute("name of DataField")
    
    isArray = Attribute("is array ?")
    
    dataType = Attribute("type of data")
    
    initialValue = Attribute("initial Value")
    
    description = Attribute("description of WFRD")


## Application Declaration

class IWfMCApplicationContainer(IContainer):
    """WfMC Application Definition Container.
    """

class IWfMCApplication(IWfMCProcessDefinitionElement):
    """WfMC Application Definition.
    """

    name = Attribute("Name of Application.")

    description = Attribute("Description of Application.")

    formalParameterList = Attribute("Sequence of Formal Parameters.")


## Participant Declaration

class IWfMCParticipantContainer(IContainer):
    """WfMC Participant Definition Container.
    """

class IWfMCParticipant(IWfMCProcessDefinitionElement):
    """WfMC Participant Definition.
    """

    name = Attribute("Name of Participant.")

    type = Attribute("""Type of Participant: RESOURCE_SET/RESOURCE/ROLE/
                        ORGANIZATIONAL_UNIT/HUMAN/SYSTEM""")

    description = Attribute("Description of Participant.")
 


## Activity 

class IWfMCActivityContainer(IContainer):
    """WfMC Activity Container.
    """

class IWfMCActivity(IWfMCProcessDefinitionElement):
    """WfMC Activity.
    """

    # we get get this via acquisition
    # processDefinition = Attribute("ref to PD the activity belongs to")
    
    name = Attribute("a Activity Name")
    
    description = Attribute("a description")
    
    isRoute = Attribute("is this a route Activity")
    
    startMode = Attribute("how Activity is started (0-Manual/1-Automatic)")
    
    finishMode = Attribute("how Activity is finished (0-Manual/1-Automatic)")
    
    performer = Attribute("link to workflow participant (may be expression)")
    
    implementation = Attribute("if not Route-Activity: mandatory (no/tool+/subflow/loop)")
    
    instantiation = Attribute("capability: once/multiple times")
    
    priority = Attribute("priority of Activity")
    
    cost = Attribute("average cost")
    
    workingTime = Attribute("amount of time, performer of activity needs to perform task")
    
    waitingTime = Attribute("amount of time, needed to prepare performance of task")
    
    duration = Attribute("duration of activity")
    
    limit = Attribute("limit in costUnits")
    
    icon = Attribute("icon of activity")
    
    documentation = Attribute("documentation")
    
    splitMode = Attribute("split Mode (and/xor)")
    
    joinMode = Attribute("join Mode (and/xor)")
    
    inlineBlock = Attribute("inline Block definition")



class IWfMCImplementation(IWfMCProcessDefinitionElement):
    """WfMC Implementation Definition.

    is referenced by Activity Attribute: implementation.
    """

    type = Attribute("Type of Implementation: NO/SUBFLOW/TOOL")


class IWfMCSubflow(IWfMCImplementation):
    """WfMC Implementation Subflow.
    """

    name = Attribute("Name of Subflow to start.")

    execution = Attribute("Type of Execution: Asynchr/synchr.")

    actualParameterList = Attribute("""Sequence of ActualParameters with those the
                                     new Instance is initialized and whose are
                                     returned.""")
    

class IWfMCTool(IWfMCImplementation):
    """WfMC Implementation Subflow.
    """

    name = Attribute("Name of Application/Procedure to invoke (Application Declaration).")

    type = Attribute("Type of Tool: APPLICATION/PROCEDURE.")

    description = Attribute("Description of Tool.")

    actualParameterList = Attribute("""Sequence of ActualParameters with those the
                                     new Instance is initialized and whose are
                                     returned.""")



## Transition

class IWfMCCondition(Interface):
    """WfMC Condition.
    """

    type = Attribute("Type of Condition: CONDITION/OTHERWISE")

    expression = Attribute("Expression to evaluate.")


class IWfMCTransitionContainer(IContainer):
    """WfMC Transition Container.
    """

class IWfMCTransition(IWfMCProcessDefinitionElement):
    """WfMC Transition.
    """

    name = Attribute("Name of Transition.")

    condition = Attribute("ref to Condition.")

    fromActivityId = Attribute("Id of FromActivity.")

    toActivityId = Attribute("Id of ToActivity.")







## ProcessInstance

class IWfMCProcessInstanceData(Interface):
    """WfMC ProcessInstance Data.

    this is a base interfaces that gets extended dynamically
    when creating a ProcessInstance from the relevantData Spec.
    """

    # XXX Not shure how to implement this.
    # probably using schemagen


class IWfMCProcessInstance(IProcessInstance):
    """WfMC Workflow process instance.
    """

    processDefinitionId = Attribute("Id of ProcessDefinition.")

    name = Attribute("Name of ProcessInstance.")

    creationTime = Attribute("Creation Time of ProcessInstance.")

    activityInstances = Attribute("ref to ActivityInstanceContainer.")

    data = Attribute("WorkflowRelevant Data (instance, not definition.)")

    # XXX Do we need an actual Participantlist for implementation ??

    


## ActivityInstance

class IWfMCActivityInstanceContainer(IContainer):
    """WfMC ActivityInstance Container.
    """
    
class IWfMCActivityInstance(Interface):
    """WfMC Workflow activity instance.
    """

    activityId = Attribute("Id of Activity.")
    
    name = Attribute("Name of ActivityInstance.")

    creationTime = Attribute("Creation Time of ActivityInstance.")

    status = Attribute("Status of ActivityInstance.")

    priority = Attribute("Priority of ActivityInstance (initialized from Activity).")

    workitems = Attribute("ref to WorkitemContainer.")

    # XXX 
    # participants = Attribute("Sequence of assigned Participants.")


## WorkItem

class IWfMCWorkitemContainer(IContainer):
    """WfMC Workitem Container.
    """

class IWfMCWorkitem(Interface):
    """WfMC Workflow  instance.
    """

    status = Attribute("Status of Workitem.")

    priority = Attribute("Priority of Workitem.")

    participant = Attribute("Participant that is assigned to do this item of Work.")