Beispiel #1
0
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 Products.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]
Beispiel #2
0
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]
Beispiel #3
0
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 = Products.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]
Beispiel #4
0
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 = Products.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]
Beispiel #5
0
class Alarm(BaseAutomaticActivity):

    attributes = BaseAutomaticActivity.attributes + (WorkflowAttribute(
        'due',
        'due', 'TALES expression that determines the date when '
        'this alarm is due.',
        required=True), )
Beispiel #6
0
class Exit(Checkpoint):

    attributes = Checkpoint.attributes + (WorkflowAttribute(
        "condition", "condition",
        "TALES expression returning True or False."), )

    def factory(self):
        return Products.AlphaFlow.interfaces.IExitDefinition(self.parent)
Beispiel #7
0
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 = Products.AlphaFlow.aspects.permission.PermissionAddSetting
Beispiel #8
0
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"),
    )
Beispiel #9
0
class DCWorkflow(Aspect):

    attributes = Aspect.attributes + (WorkflowAttribute(
        'status',
        'status',
        'Status which is set as DCWorkFlow status.',
        required=True,
        encoding='ascii',
        datatype=str), )
Beispiel #10
0
class SimpleDecision(BaseAssignableActivity):

    attributes = BaseAssignableActivity.attributes + (WorkflowAttribute(
        'decision_notice', 'decision_notice',
        'Describing the task for the decision.'), )

    checkpoints = BaseAssignableActivity.checkpoints + (
        ExitFromNode("accept"),
        ExitFromNode("reject"),
    )
Beispiel #11
0
class Parent(Aspect):

    attributes = Aspect.attributes + (WorkflowAttribute(
        'parentOf',
        'continue_with_parent_of',
        'Continue with parent of this activity.',
        required=True,
        encoding='ascii',
        datatype=str,
    ), )
Beispiel #12
0
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'), )
Beispiel #13
0
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.'
        ))
Beispiel #14
0
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), )
Beispiel #15
0
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"), )
Beispiel #16
0
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]
Beispiel #17
0
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]
Beispiel #18
0
        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):