Module: CurationConcerns::Workflow

Defined in:
app/services/curation_concerns/workflow/activate_object.rb,
app/services/curation_concerns/workflow/workflow_schema.rb,
app/services/curation_concerns/workflow/method_generator.rb,
app/services/curation_concerns/workflow/permission_query.rb,
app/services/curation_concerns/workflow/workflow_factory.rb,
app/services/curation_concerns/workflow/deactivate_object.rb,
app/services/curation_concerns/workflow/workflow_importer.rb,
app/services/curation_concerns/workflow/status_list_service.rb,
app/services/curation_concerns/workflow/action_taken_service.rb,
app/services/curation_concerns/workflow/notification_service.rb,
app/services/curation_concerns/workflow/permission_generator.rb,
app/services/curation_concerns/workflow/notification_generator.rb,
app/services/curation_concerns/workflow/grant_edit_to_depositor.rb,
app/services/curation_concerns/workflow/state_machine_generator.rb,
app/services/curation_concerns/workflow/workflow_action_service.rb,
app/services/curation_concerns/workflow/sipity_actions_generator.rb,
app/services/curation_concerns/workflow/default_workflow_strategy.rb,
app/services/curation_concerns/workflow/workflow_permissions_generator.rb,
app/services/curation_concerns/workflow/workflow_by_model_name_strategy.rb,
app/services/curation_concerns/workflow/notification_configuration_parameter.rb

Defined Under Namespace

Modules: PermissionQuery Classes: ActionTakenService, ActivateObject, DeactivateObject, DefaultWorkflowStrategy, GrantEditToDepositor, MethodGenerator, NotificationConfigurationParameter, NotificationGenerator, NotificationService, PermissionGenerator, SipityActionsGenerator, StateMachineGenerator, StatusListService, WorkflowActionService, WorkflowByModelNameStrategy, WorkflowFactory, WorkflowImporter, WorkflowPermissionsGenerator

Constant Summary collapse

WorkflowSchema =

Responsible for describing the JSON schema for a Workflow.

The ‘workflows name` defines the name of the Sipity::Workflow. The `workflows actions` defines the actions that can be taken in the given states (e.g. :from_states) by the given :roles. The `workflows actions transition_to` defines the state to which we transition when the action is taken. The `workflows actions notifications` defines the notifications that should be sent when the action is taken.

See Also:

Dry::Validation.Schema do
  configure do
    def self.messages
      Dry::Validation::Messages.default.merge(
        en: { errors: { constant_name?: 'must be an initialized Ruby constant' } }
      )
    end

    def constant_name?(value)
      value.constantize
      true
    rescue NameError
      false
    end
  end

  required(:workflows).each do
    required(:name).filled(:str?) # Sipity::Workflow#name
    optional(:label).filled(:str?) # Sipity::Workflow#label
    optional(:description).filled(:str?) # Sipity::Workflow#description
    optional(:allows_access_grant).filled(:bool?) # Sipity::Workflow#allows_access_grant?
    required(:actions).each do
      required(:name).filled(:str?) # Sipity::WorkflowAction#name
      required(:from_states).each do
        required(:names) { array? { each(:str?) } } # Sipity::WorkflowState#name
        required(:roles) { array? { each(:str?) } } # Sipity::Role#name
      end
      optional(:transition_to).filled(:str?) # Sipity::WorkflowState#name
      optional(:notifications).each do
        required(:name).value(:constant_name?) # Sipity::Notification#name
        required(:notification_type).value(included_in?: Sipity::Notification.valid_notification_types)
        required(:to) { array? { each(:str?) } }
        optional(:cc) { array? { each(:str?) } }
        optional(:bcc) { array? { each(:str?) } }
      end
      optional(:methods) { array? { each(:str?) } }
    end
  end
end