class PermissionSetting(DOMImporterBase): zope.component.adapts(IPermissionAspectDefinition) attributes = ( WorkflowAttribute('permission', 'name', 'The permission affected.', encoding="ascii", datatype=str), WorkflowAttribute('roles', 'roles', 'Sequence of affected roles.', encoding="ascii", datatype=tuple), WorkflowAttribute('acquire', 'acquire', '(bool) acquire permission or not.', datatype=bool), ) _factory = gocept.alphaflow.aspects.permission.PermissionSetting def __call__(self, node, setting=None): # XXX feed the factory with dummy values, should be refactored setting = self._factory(None, None, None) configure_attributes(node, setting, self.attributes) return [setting]
class Aspect(DOMImporterBase): zope.component.adapts(ICheckpointDefinition) attributes = ( WorkflowAttribute('id', 'id', 'Id of the activity', encoding="utf-8", datatype=str), WorkflowAttribute('title', 'title', 'Title of the activity.'), WorkflowAttribute('sortPriority', 'sort', 'Lower priority activities will be shown first.', datatype=int), WorkflowAttribute('nonEditableFields', 'nonEditableFields', 'Fields in schema which are not to be edited ' 'aka configured by user of workflow.', datatype=tuple), WorkflowAttribute('commentfield', 'commentfield', 'Should the commentfield be hidden or have ' 'required input?', datatype=str), ) def __call__(self, node, aspect=None): name = self.__class__.__name__.lower() if name.endswith("aspect"): name = name[:-len("aspect")] factory = zope.component.getUtility(IAspectDefinitionClass, name=name) aspect = factory() configure_attributes(node, aspect, self.attributes) return [aspect]
class Checkpoint(DOMImporterBase): zope.component.adapts(IActivity) attributes = ( WorkflowAttribute('id', 'id', 'Id of the exit.', encoding="ascii", datatype=str), WorkflowAttribute('title', 'title', 'Title of the exit.'), WorkflowAttribute('activities', 'activities', 'Continue activities if this exit gets chosen.', encoding='ascii', datatype=tuple), ) def factory(self): return gocept.alphaflow.checkpoint.CheckpointDefinition() def __call__(self, node, checkpoint=None): if not checkpoint: checkpoint = self.factory() configure_attributes(node, checkpoint, self.attributes) add_child_elements(node, checkpoint, "Aspect") return [checkpoint]
class PermissionAddSetting(PermissionSetting): zope.component.adapts(IPermissionAspectDefinition) attributes = (WorkflowAttribute('permission', 'name', 'The permission affected.', encoding="ascii", datatype=str), WorkflowAttribute('roles', 'roles', 'Sequence of affected roles.', encoding="ascii", datatype=tuple), ) _factory = gocept.alphaflow.aspects.permission.PermissionAddSetting
class Recipient(DOMImporterBase): # Distinguish the various recipient modes and create # recipient objects actual_role = (WorkflowAttribute('roles', 'roles', 'Members with this roles get an e-mail.', required=True, encoding="ascii", datatype=tuple), ) def __call__(self, node, recipient=None): notify = gocept.alphaflow.activities.notify recipient_type = node.getAttribute("type") if recipient_type == "owner": recipient = notify.RecipientOwner() elif recipient_type == "next_assignees": recipient = notify.RecipientNextAssignees() elif recipient_type == "current_assignees": recipient = notify.RecipientCurrentAssignees() elif recipient_type == "previous_assignees": recipient = notify.RecipientPreviousAssignees() elif recipient_type == "actual_role": recipient = notify.RecipientActualRole() configure_attributes(node, recipient, self.actual_role) else: raise ConfigurationError( "Unknown recipient type: " + recipient_type) return [recipient]
class Alarm(BaseAutomaticActivity): attributes = BaseAutomaticActivity.attributes + ( WorkflowAttribute('due', 'due', 'TALES expression that determines the date when ' 'this alarm is due.', required=True),)
class DCWorkflow(Aspect): attributes = Aspect.attributes + ( WorkflowAttribute('status', 'status', 'Status which is set as DCWorkFlow status.', required=True, encoding='ascii', datatype=str), )
class Parent(Aspect): attributes = Aspect.attributes + ( WorkflowAttribute('parentOf', 'continue_with_parent_of', 'Continue with parent of this activity.', required=True, encoding='ascii', datatype=str, ), )
class Decision(BaseAssignableActivity): known_decision_modi = ['first_yes', 'all_yes'] attributes = BaseAssignableActivity.attributes + ( WorkflowAttribute('decision_notice', 'decision_notice', 'Describing the task for the decision.'), WorkflowAttribute('decision_modus', 'decision_modus', 'One of self.known_decision_modi', required=True, vocabulary=known_decision_modi), ) checkpoints = BaseAssignableActivity.checkpoints + ( ExitFromNode("accept"), ExitFromNode("reject"), )
class Exit(Checkpoint): attributes = Checkpoint.attributes + ( WorkflowAttribute("condition", "condition", "TALES expression returning True or False."),) def factory(self): return gocept.alphaflow.interfaces.IExitDefinition(self.parent)
class BaseAssignableActivity(BaseActivity): attributes = BaseActivity.attributes + ( WorkflowAttribute('viewUrlExpression', 'view_url_expr', '(TALES expression) URL to "view" a workitem, ' 'e.g. "Edit document" points to the edit-tab'), WorkflowAttribute('showInWorkList', 'show_in_work_list', 'Whether to include the work item in work lists.', datatype=bool), WorkflowAttribute('contentRoles', 'content_roles', 'Roles which assigned users get on the ' 'content object.', encoding='ascii', datatype=tuple), AssigneesAttribute(), WorkflowAttribute('completionUrlExpression', 'completion_url_expr', '(TALES Expression) URL to redirect a user to after completing the workitem.' 'If empty or unspecified the URL will be determined the default algorithms.') )
class SimpleDecision(BaseAssignableActivity): attributes = BaseAssignableActivity.attributes + (WorkflowAttribute( 'decision_notice', 'decision_notice', 'Describing the task for the decision.'), ) checkpoints = BaseAssignableActivity.checkpoints + ( ExitFromNode("accept"), ExitFromNode("reject"), )
class Gate(BaseAutomaticActivity): mode_types = (MULTI_MERGE, DISCRIMINATE, DELAYED_DISCRIMINATE, SYNCHRONIZING_MERGE,) attributes = BaseAutomaticActivity.attributes + ( WorkflowAttribute('mode', 'mode', 'Mode the gate works, values see self.mode_types', required=True, encoding='ascii', datatype=str, vocabulary=mode_types), )
class Switch(BaseActivity): attributes = BaseAutomaticActivity.attributes + (WorkflowAttribute( 'mode', 'mode', 'Whether to create WorkItems for only the ' 'first or all cases yielding True.', required=True, datatype=str, vocabulary=('first', 'all')), ) checkpoints = BaseAssignableActivity.checkpoints + ( MultipleExitsFromNodes('case'), )
class Configuration(BaseAssignableActivity): attributes = BaseAssignableActivity.attributes + ( # viewUrlExpression overwrites existing viewUrlExpression WorkflowAttribute('viewUrlExpression', 'view_url_expr', '(TALES expression) URL to "view" a workitem, ' 'e.g. "Edit document" points to the edit-tab'), ConfiguresAttribute('configures', 'configures', 'Other activities which are configured by this ' 'activity or None as marker for all activities.', encoding='ascii', datatype=tuple), ) checkpoints = BaseAssignableActivity.checkpoints + ( ExitFromNode("complete"), )
class BaseActivity(DOMImporterBase): zope.component.adapts(IActivityContainer) attributes = (WorkflowAttribute('id', 'id', 'Id of the activity', required=True, encoding="utf-8", datatype=str), WorkflowAttribute('title', 'title', 'Title of the activity.'), WorkflowAttribute( 'sortPriority', 'sort', 'Lower priority activities will be shown first.', datatype=int), WorkflowAttribute( 'nonEditableFields', 'nonEditableFields', 'Fields in schema which are not to be edited ' 'aka configured by user of workflow.', datatype=tuple), WorkflowAttribute( 'commentfield', 'commentfield', 'Should the commentfield be hidden or have ' 'required input?', datatype=str), WorkflowAttribute('group', 'group', 'The group this activity belongs to.', datatype=str)) checkpoints = ( CheckpointFromNode("start", config.CHECKPOINT_START), CheckpointFromNode("end", config.CHECKPOINT_COMPLETE), ) def __call__(self, node, activity=None): name = self.__class__.__name__.lower() factory = zope.component.getUtility(IActivityClass, name=name) activity = factory() configure_attributes(node, activity, self.attributes) for descriptor in self.checkpoints: descriptor.apply(node, activity) return [activity]
class ProcessVersionImporter(object): zope.interface.implements(IDOMImporter) attributes = ( WorkflowAttribute('id', 'id', 'Id of the process', encoding="utf-8", datatype=str), WorkflowAttribute('title', 'title', 'Title of this process definition.'), WorkflowAttribute('startActivity', 'startActivity', 'List of activity ids to instantiate at start.', encoding='ascii', datatype=tuple), WorkflowAttribute('description', 'description', 'Description of this process definition.'), WorkflowAttribute('roles', 'onlyAllowRoles', 'Only members with this roles my start this workflow.', encoding='ascii', datatype=list), WorkflowAttribute('object_name', 'object_name', 'Name the content object is bound to in expressions.', encoding='ascii', datatype=str), ) def __call__(self, process_node): process = ProcessVersion() # Configure the process' simple attributes configure_attributes(process_node, process, self.attributes) # Import all activities for node in get_element_children(process_node): activity_importer = zope.component.getAdapter( process, IDOMImporter, name=node.nodeName) for activity in activity_importer(node): process[activity.getId()] = activity return [process]
'Describing the task for the decision.'), WorkflowAttribute('decision_modus', 'decision_modus', 'One of self.known_decision_modi', required=True, vocabulary=known_decision_modi), ) checkpoints = BaseAssignableActivity.checkpoints + ( ExitFromNode("accept"), ExitFromNode("reject"), ) expression_attributes = ( WorkflowAttribute('expression', 'expression', 'TALES expression which is to be executed.', required=True), WorkflowAttribute('runAs', 'runAs', 'TALES expression returning the user to run as.', required=False), ) class Expression(BaseAutomaticActivity): attributes = BaseAutomaticActivity.attributes + expression_attributes class ExpressionAspect(Aspect): attributes = Aspect.attributes + expression_attributes