Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
ITransitionDefinition was not well-defined,
Browse files Browse the repository at this point in the history
minor flaws in process elements __name__ and description handling and reading from XPDL
  • Loading branch information
Adam Groszer committed Sep 8, 2006
1 parent c616213 commit f4ac0ba
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
19 changes: 19 additions & 0 deletions interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class IActivityDefinition(interface.Interface):
"""

id = interface.Attribute("Activity identifier")

__name__ = interface.Attribute("Activity Name")

description = interface.Attribute("Description")

def addApplication(id, *parameters):
"""Declare that the activity uses the identified activity
Expand Down Expand Up @@ -167,6 +171,21 @@ def setAndJoin(setting):
class ITransitionDefinition(interface.Interface):
"""Transition definition
"""
id = interface.Attribute("Transition identifier")

__name__ = interface.Attribute(
"Transition name, Text used to identify the Transition.")

description = interface.Attribute("Description")

from_ = interface.Attribute(
"Determines the FROM source of a Transition. (Activity Identifier)")

to = interface.Attribute(
"Determines the TO target of a Transition (Activity Identifier)")

condition = interface.Attribute(
"A Transition condition expression based on relevant data field.")

class IProcess(interface.Interface):
"""Process instance
Expand Down
7 changes: 6 additions & 1 deletion process.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ class TransitionDefinition(object):

interface.implements(interfaces.ITransitionDefinition)

def __init__(self, from_, to, condition=always_true, id=None):
def __init__(self, from_, to, condition=always_true, id=None, __name__=None):
self.id = id
self.from_ = from_
self.to = to
self.condition = condition
self.__name__ = __name__
self.description = None

def __repr__(self):
return "TransitionDefinition(from=%r, to=%r)" %(self.from_, self.to)
Expand All @@ -57,6 +59,7 @@ def __init__(self, id, integration=None):
self.applications = {}
self.participants = {}
self.parameters = ()
self.description = None

def __repr__(self):
return "ProcessDefinition(%r)" % self.id
Expand Down Expand Up @@ -144,6 +147,7 @@ def __init__(self, __name__=None):
self.transition_outgoing = self.explicit_outgoing = ()
self.applications = ()
self.andJoinSetting = self.andSplitSetting = False
self.description = None

def andSplit(self, setting):
self.andSplitSetting = setting
Expand Down Expand Up @@ -486,6 +490,7 @@ class Participant:

def __init__(self, name=None):
self.__name__ = name
self.description = None

def __repr__(self):
return "Participant(%r)" %self.__name__
10 changes: 7 additions & 3 deletions publication.xpdl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<WorkflowProcess AccessLevel="PUBLIC" Id="Publication" Name="Publication">
<ProcessHeader DurationUnit="D">
<Created>2005-01-06 16:29:02</Created>
<Description>This is the sample process</Description>
</ProcessHeader>
<RedefinableHeader PublicationStatus="UNDER_TEST"/>
<FormalParameters>
Expand Down Expand Up @@ -86,6 +87,7 @@
</Participant>
<Participant Id="tech1" Name="Technical Reviewer 1">
<ParticipantType Type="HUMAN"/>
<Description>He is a smart guy.</Description>
</Participant>
<Participant Id="tech2" Name="Technical Reviewer 2">
<ParticipantType Type="HUMAN"/>
Expand Down Expand Up @@ -192,6 +194,7 @@
</ExtendedAttributes>
</Activity>
<Activity Id="tech1" Name="Technical Review 1">
<Description>This is the first Technical Review.</Description>
<Implementation>
<Tool Id="tech_review" Type="APPLICATION">
<ActualParameters>
Expand Down Expand Up @@ -386,13 +389,13 @@
</Activity>
</Activities>
<Transitions>
<Transition From="prepare" Id="Publication_Tra2" Name="Transition" To="tech1">
<Transition From="prepare" Id="Publication_Tra2" Name="Transition to Tech Review 1" To="tech1">
<ExtendedAttributes>
<ExtendedAttribute Name="RoutingType" Value="NOROUTING"/>
<ExtendedAttribute Name="BreakPoint" Value="160;160;1"/>
</ExtendedAttributes>
</Transition>
<Transition From="prepare" Id="Publication_Tra3" Name="Transition" To="tech2">
<Transition From="prepare" Id="Publication_Tra3" Name="Transition to Tech Review 2" To="tech2">
<ExtendedAttributes>
<ExtendedAttribute Name="RoutingType" Value="NOROUTING"/>
<ExtendedAttribute Name="BreakPoint" Value="210;290;1"/>
Expand Down Expand Up @@ -421,6 +424,7 @@
</Transition>
<Transition From="review" Id="Publication_Tra8" Name="Transition" To="final">
<Condition Type="CONDITION">ed_changes</Condition>
<Description>Use this transition if there are editorial changes required.</Description>
<ExtendedAttributes>
<ExtendedAttribute Name="RoutingType" Value="NOROUTING"/>
</ExtendedAttributes>
Expand Down Expand Up @@ -462,6 +466,6 @@
</WorkflowProcesses>
<ExtendedAttributes>
<ExtendedAttribute Name="MadeBy" Value="JaWE"/>
<ExtendedAttribute Name="Version" Value="1.2"/>
<ExtendedAttribute Name="Version" Value="1.4.2"/>
</ExtendedAttributes>
</Package>
2 changes: 2 additions & 0 deletions xpdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def Participant(self, attrs):
name = attrs.get((None, 'Name'))
participant = self.ParticipantFactory(name)
self.stack[-1].defineParticipants(**{str(id): participant})
return participant
start_handlers[(xpdlns, 'Participant')] = Participant

def Application(self, attrs):
Expand Down Expand Up @@ -236,6 +237,7 @@ def Transition(self, attrs):
to = attrs.get((None, 'To'))
transition = self.TransitionDefinitionFactory(from_, to)
transition.id = id
transition.__name__ = name
return transition
start_handlers[(xpdlns, 'Transition')] = Transition

Expand Down
26 changes: 24 additions & 2 deletions xpdl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,13 @@ Descriptions
============

Most process elements can have names and descriptions.


>>> pd.__name__
u'Publication'

>>> pd.description
u'This is the sample process'

>>> pd.applications['prepare'].__name__
u'Prepare'

Expand All @@ -362,5 +368,21 @@ Most process elements can have names and descriptions.
>>> pd.activities['tech1'].__name__
u'Technical Review 1'

>>> pd.activities['tech1'].description
u'This is the first Technical Review.'

>>> pd.participants['tech1'].__name__
u'Technical Reviewer 1'
u'Technical Reviewer 1'

>>> pd.participants['tech1'].description
u'He is a smart guy.'

>>> sorted([item.__name__ for item in pd.transitions])
[u'Transition', u'Transition', u'Transition', u'Transition',
u'Transition', u'Transition', u'Transition', u'Transition',
u'Transition', u'Transition', u'Transition to Tech Review 1',
u'Transition to Tech Review 2']

>>> sorted([item.description for item in pd.transitions])
[None, None, None, None, None, None, None, None, None, None, None,
u'Use this transition if there are editorial changes required.']

0 comments on commit f4ac0ba

Please sign in to comment.